Depending of your version of CGI, the header function will look a little different, but here is the basic jist of it
#### Method: header # Return a Content-Type: style header # #### 'header' => <<'END_OF_FUNC', sub header { my($self,@p) = self_or_default(@_); my(@header); return undef if $self->{'.header_printed'}++ and $HEADERS_ONCE; my($type,$status,$cookie,$target,$expires,$nph,$charset,$attachmen +t,@other) = rearrange([['TYPE','CONTENT_TYPE','CONTENT-TYPE'], 'STATUS',['COOKIE','COOKIES'],'TARGET', 'EXPIRES','NPH','CHARSET', 'ATTACHMENT'],@p); $nph ||= $NPH; if (defined $charset) { $self->charset($charset); } else { $charset = $self->charset; } # rearrange() was designed for the HTML portion, so we # need to fix it up a little. foreach (@other) { next unless my($header,$value) = /([^\s=]+)=\"?(.+?)\"?$/; ($_ = $header) =~ s/^(\w)(.*)/$1 . lc ($2) . ': '.$self->unescapeH +TML($value)/e; } $type ||= 'text/html' unless defined($type); $type .= "; charset=$charset" if $type ne '' and $type =~ m!^text/ +! and $type !~ /\bcharset\b/; # Maybe future compatibility. Maybe not. my $protocol = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0'; push(@header,$protocol . ' ' . ($status || '200 OK')) if $nph; push(@header,"Server: " . &server_software()) if $nph; push(@header,"Status: $status") if $status; push(@header,"Window-Target: $target") if $target; # push all the cookies -- there may be several if ($cookie) { my(@cookie) = ref($cookie) && ref($cookie) eq 'ARRAY' ? @{$cookie} + : $cookie; foreach (@cookie) { my $cs = UNIVERSAL::isa($_,'CGI::Cookie') ? $_->as_string +: $_; push(@header,"Set-Cookie: $cs") if $cs ne ''; } } # if the user indicates an expiration time, then we need # both an Expires and a Date header (so that the browser is # uses OUR clock) push(@header,"Expires: " . expires($expires,'http')) if $expires; push(@header,"Date: " . expires(0,'http')) if $expires || $cookie +|| $nph; push(@header,"Pragma: no-cache") if $self->cache(); push(@header,"Content-Disposition: attachment; filename=\"$attachm +ent\"") if $attachment; push(@header,@other); push(@header,"Content-Type: $type") if $type ne ''; my $header = join($CRLF,@header)."${CRLF}${CRLF}"; if ($MOD_PERL and not $nph) { my $r = Apache->request; $r->send_cgi_header($header); return ''; } return $header; } END_OF_FUNC
The header function behaves as it should. The reason you get the so called eyesore, is because the header has already been printed, and you're attempting to print it again, so at this point, it might be formatted like a header, but it's treated as content. The key value pairs that make up the http header are usually referred to as "http headers" but they're just fields of the http header. The http header is terminated by a "\n\n", which is what most people leave out when first printing a header on their own, and that is the purpose of the header function, to make sure a valid header is printed (one terminated with \n\n)....

I suggest you learn more about HTTP and CGI, as well as read CGI.pm (in this case at least the header funtion), and you'll see why the answer to your question is yes.


In reply to Re: Header Visible In CGI output after cookie header is sent by Anonymous Monk
in thread Header Visible In CGI output after cookie header is sent by jerrygarciuh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.