line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::PrintWrapper; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This is a lightweight wrapper for CGI so that you can call its |
4
|
|
|
|
|
|
|
# methods, but have the results printed to the request object (passing |
5
|
|
|
|
|
|
|
# through the Template object, of course). |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
24514
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
126
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
16
|
use Carp ( ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
41
|
|
10
|
3
|
|
|
3
|
|
19913
|
use CGI ( ); |
|
3
|
|
|
|
|
72536
|
|
|
3
|
|
|
|
|
89
|
|
11
|
3
|
|
|
3
|
|
3823
|
use CGI::Pretty; |
|
3
|
|
|
|
|
5669
|
|
|
3
|
|
|
|
|
18
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$CGI::PrintWrapper::VERSION = (substr q$Revision: 1.8 $, 10) - 1; |
15
|
|
|
|
|
|
|
my $rcs = '$Id: PrintWrapper.pm,v 1.8 1999/12/30 13:38:06 binkley Exp $'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new ($$;@) { |
19
|
4
|
|
|
4
|
1
|
3205
|
my ($this, $h, @cgi_args) = @_; |
20
|
4
|
100
|
|
|
|
19
|
@cgi_args = ('') unless @cgi_args; |
21
|
|
|
|
|
|
|
|
22
|
4
|
50
|
|
|
|
18
|
$h or Carp::croak ('No print handle'); |
23
|
4
|
50
|
|
|
|
34
|
$h->can ('print') or Carp::croak ("'$h' is not a print handle"); |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
33
|
|
|
26
|
my $class = ref ($this) || $this; |
26
|
|
|
|
|
|
|
# Need to create an empty CGI object to avoid CGI trying to read in |
27
|
|
|
|
|
|
|
# the parameters -- we are using CGI for printing forms, not for |
28
|
|
|
|
|
|
|
# processing scripts: |
29
|
4
|
|
|
|
|
6
|
my $cgi; |
30
|
4
|
|
|
|
|
8
|
eval { $cgi = CGI->new (@cgi_args); }; |
|
4
|
|
|
|
|
23
|
|
31
|
4
|
50
|
|
|
|
11238
|
$@ and Carp::croak ("Couldn't create CGI object because $@"); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
24
|
bless [$h, $cgi], $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub io ($;$) { |
37
|
3
|
50
|
|
3
|
1
|
16
|
if (scalar @_ == 1) { |
38
|
3
|
|
|
|
|
44
|
$_[0]->[0]; |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
0
|
$_[0]->[0] = $_[1]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Modify CGI without printing: |
45
|
|
|
|
|
|
|
sub cgi ($;$) { |
46
|
2
|
50
|
|
2
|
1
|
28
|
if (scalar @_ == 1) { |
47
|
2
|
|
|
|
|
9
|
$_[0]->[1]; |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
0
|
$_[0]->[1] = $_[1]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub AUTOLOAD { |
54
|
3
|
|
|
3
|
|
1075
|
no strict qw(refs); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
534
|
|
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
3
|
|
1126
|
my $sub = $CGI::PrintWrapper::AUTOLOAD; |
57
|
3
|
|
|
|
|
15
|
$sub =~ s/.*:://; # strip package |
58
|
|
|
|
|
|
|
# We don't particularly want to print this: :-) |
59
|
3
|
50
|
|
|
|
13
|
return if $sub eq 'DESTROY'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Fixup our call to invoke the same-named CGI function, but to print |
62
|
|
|
|
|
|
|
# the resulting string to our handle. Update our symbol table so |
63
|
|
|
|
|
|
|
# that future calls can bypass AUTOLOAD entirely. Be careful to |
64
|
|
|
|
|
|
|
# capture the handle ($$self) inside the sub--not outside--so that |
65
|
|
|
|
|
|
|
# calls from other instances don't reuse a previous handle (correct |
66
|
|
|
|
|
|
|
# scoping): |
67
|
3
|
|
|
|
|
42
|
*{$CGI::PrintWrapper::AUTOLOAD} = sub { |
68
|
5
|
|
|
5
|
|
496
|
my $self = shift; |
69
|
5
|
|
|
|
|
13
|
my $cgi_sub = "CGI::$sub"; |
70
|
|
|
|
|
|
|
|
71
|
5
|
|
|
|
|
90
|
$self->[0]->print ($self->[1]->$cgi_sub (@_)); |
72
|
|
|
|
|
|
|
|
73
|
5
|
|
|
|
|
10478
|
return $self; |
74
|
3
|
|
|
|
|
18
|
}; |
75
|
|
|
|
|
|
|
|
76
|
3
|
|
|
|
|
13
|
goto &$CGI::PrintWrapper::AUTOLOAD; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |