File Coverage

blib/lib/CGI/Pretty.pm
Criterion Covered Total %
statement 37 37 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1             package CGI::Pretty;
2              
3 1     1   68524 use strict;
  1         14  
  1         35  
4 1     1   7 use warnings;
  1         2  
  1         51  
5              
6 1     1   529 use if $] >= 5.019, 'deprecate';
  1         14  
  1         7  
7 1     1   1630 use CGI ();
  1         5  
  1         162  
8              
9             $CGI::Pretty::VERSION = '4.37';
10             $CGI::DefaultClass = __PACKAGE__;
11             @CGI::Pretty::ISA = qw( CGI );
12              
13             sub new {
14 1     1 1 2 my $class = shift;
15 1         9 my $this = $class->SUPER::new( @_ );
16 1         6 return bless $this, $class;
17             }
18              
19             sub import {
20              
21 1     1   145 warn "CGI::Pretty is DEPRECATED and will be removed in a future release. Please see https://github.com/leejo/CGI.pm/issues/162 for more information";
22              
23 1         7 my $self = shift;
24 1     1   10 no strict 'refs';
  1         4  
  1         299  
25              
26             # This causes modules to clash.
27 1         4 undef %CGI::EXPORT;
28 1         3 undef %CGI::EXPORT;
29              
30 1         12 $self->_setup_symbols(@_);
31 1         7 my ($callpack, $callfile, $callline) = caller;
32              
33             # To allow overriding, search through the packages
34             # Till we find one in which the correct subroutine is defined.
35 1         3 my @packages = ($self,@{"$self\:\:ISA"});
  1         8  
36 1         30 foreach my $sym (keys %CGI::EXPORT) {
37 172         321 my $pck;
38 172         292 my $def = $CGI::DefaultClass;
39 172         341 foreach $pck (@packages) {
40 344 100       569 if (defined(&{"$pck\:\:$sym"})) {
  344         1509  
41 172         665 $def = $pck;
42 172         298 last;
43             }
44             }
45 172         277 *{"${callpack}::$sym"} = \&{"$def\:\:$sym"};
  172         2848  
  172         419  
46             }
47             }
48              
49             1;
50              
51             =head1 NAME
52              
53             CGI::Pretty - module to produce nicely formatted HTML code
54              
55             =head1 CGI::Pretty IS DEPRECATED
56              
57             It will be removed from the CGI distribution in a future release, so you
58             should no longer use it and remove it from any code that currently uses it.
59              
60             For now it has been reduced to a shell to prevent your code breaking, but
61             the "pretty" functions will no longer output "pretty" HTML.
62              
63             =head1 Alternatives
64              
65             L + L + L:
66              
67             print HTML::HTML5::Writer->new(
68             start_tags => 'force',
69             end_tags => 'force',
70             )->document(
71             XML::LibXML::PrettyPrint->new_for_html( indent_string => "\t" )
72             ->pretty_print(
73             HTML::HTML5::Parser->new->parse_string( $html_string )
74             )
75             );
76              
77             L (see the html_fmt script for examples)
78              
79             L
80              
81             L
82              
83             =cut