in reply to Did I already print a header?
The only way I know of to actually find out if the header has been printed to to examine the CGI object itself.
As you can see, the object tracks if the header has been printed, but that's not a good thing to rely on as you shouldn't be messing with the internals. The following will test for a printed header:$ perl -MData::Dumper -e "use CGI; my $q = CGI->new;print $q->header; +print Dumper($q)" Content-Type: text/html; charset=ISO-8859-1 $VAR1 = bless( { '.header_printed' => '1', '.charset' => 'ISO-8859-1', '.parameters' => [], '.fieldnames' => {} }, 'CGI' );
Again, that will work, but I don't recommend it. If anyone knows if CGI has a direct method for accessing that information, chime in!use CGI; my $q = new CGI; # do a whole bunch of stuff print "header printed!" if exists $q->{'.header_printed'};
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Ovid) Re: (jptxs) Did I already print a header?
by jptxs (Curate) on Nov 30, 2000 at 01:03 UTC | |
by Ovid (Cardinal) on Nov 30, 2000 at 01:09 UTC |