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   13009 use strict;
  1         1  
  1         22  
4 1     1   3 use warnings;
  1         2  
  1         27  
5              
6 1     1   482 use if $] >= 5.019, 'deprecate';
  1         7  
  1         3  
7 1     1   1374 use CGI ();
  1         3  
  1         91  
8              
9             $CGI::Pretty::VERSION = '4.36';
10             $CGI::DefaultClass = __PACKAGE__;
11             @CGI::Pretty::ISA = qw( CGI );
12              
13             sub new {
14 1     1 1 3 my $class = shift;
15 1         11 my $this = $class->SUPER::new( @_ );
16 1         2 return bless $this, $class;
17             }
18              
19             sub import {
20              
21 1     1   47 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         3 my $self = shift;
24 1     1   6 no strict 'refs';
  1         1  
  1         174  
25              
26             # This causes modules to clash.
27 1         2 undef %CGI::EXPORT;
28 1         1 undef %CGI::EXPORT;
29              
30 1         7 $self->_setup_symbols(@_);
31 1         4 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         1 my @packages = ($self,@{"$self\:\:ISA"});
  1         4  
36 1         16 foreach my $sym (keys %CGI::EXPORT) {
37 172         99 my $pck;
38 172         112 my $def = $CGI::DefaultClass;
39 172         111 foreach $pck (@packages) {
40 344 100       165 if (defined(&{"$pck\:\:$sym"})) {
  344         699  
41 172         95 $def = $pck;
42 172         112 last;
43             }
44             }
45 172         119 *{"${callpack}::$sym"} = \&{"$def\:\:$sym"};
  172         1611  
  172         155  
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