in reply to Re: Checking a header is printed already?
in thread Checking a header is printed already?

Oh , CGI,
#### Method: header # Return a Content-Type: style header # #### 'header' => <<'END_OF_FUNC', sub header { my($self,@p) = self_or_default(@_); my(@header); return "" if $self->{'.header_printed'}++ and $HEADERS_ONCE;
# Change this to 1 to suppress redundant HTTP headers $HEADERS_ONCE = 0;
$HEADERS_ONCE++, next if /^[:-]unique_headers$/;
use CGI qw( -unique_headers );

Replies are listed 'Best First'.
Re^3: Checking a header is printed already?
by Bloodnok (Vicar) on Oct 06, 2009 at 11:56 UTC
    Hmmm, utilising & referencing a modules' implementation details ... definitely a bad idea!!

    A user level that continues to overstate my experience :-))
      Hmmm, utilising & referencing a modules' implementation details ... definitely a bad idea!!

      How? You think there is another choice with CGI.pm? CGI::Simple OTOH actually documents -unique_header

        How? You think there is another choice with CGI.pm?

        Yep e.g. provide a wrapper - as I suggested elsewhere or, alternatively (and preferrably), use the unique_header package option (as AM points out).

        A user level that continues to overstate my experience :-))
Re^3: Checking a header is printed already?
by ultranerds (Hermit) on Oct 06, 2009 at 12:11 UTC
    Hi,

    Thanks for the replies guys.

    From looking at that header() bit in CGI.pm, it looks like CGI.pm already does the checking for me? (maybe that would explain why I'm not seing "Content-Type: text/html" printed several times, where the header is called :)

    Thanks!

    Andy
      It is an option, you enable it with
      use CGI qw( -unique_headers );
        Ok great, thanks agai for your help :)

        Cheers

        Andy