Fellow monasterians,
I was just about ready to post this yesterday and then thought I had a solution after reading
this answer. NOT.
I'm using HTML:Template to render my pages. So, I have the obligatory:
print "Content-type: text/html\n\n";
print $template->output();
However, sometimes, not always, before the pages are output, I use CGI to write a cookie:
my $newcookie = $query->cookie(
-name=>'gardensessionID',
-value=> $sessionnum,
-expires=>'+24h');
print $query->header(-cookie=>$newcookie);
Those times when a cookie is written, the 'unsightly'
Content-type... line is printed to the top of my output page. Here's a summary of how my script flows:
1. at top of script, a new template file name A is defined
2a. script is routed to subroutines which
do not write a cookie, OR...
2b. is routed to a subroutines which
do write a cookie, and defines a new file name B
3. either subroutine returns to output the defined page
Question: how do I arrange the use of the
print "Content-type..." line to avoid printing it to screen in instances of 2b? Thanks in advance!
P.S. You can see the entire script on my
scratchpad (experienced monks could have a field day with the rest of the code--but I'm still learning).
—Brad
"A little yeast leavens the whole dough."
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.