Coplan has asked for the wisdom of the Perl Monks concerning the following question:
Now, in some situations, I would like to manipulate header information. I can generate the header separately, but I would like to manipulate it from some of these subroutines. Specifically, I'd like to create a refresh meta tag, and I would like to have cookie information set by some of these subroutines. The problem is that I cannot seem to figure out how to return anything other than the following code snippet (I will explain variables after the code -- the program is way too large to paste here):
open(FILE, "<$template") or die "Template : Couldn't open $template : +$!\n"; while (<FILE>) { $HTML .= $_ } close(FILE); while ($HTML =~ /<!-- fillin\((.+?)\) -->/) { my $command_output = &{$templateCall->{$1}}; # a subroutine call $HTML =~ s/<!-- fillin\(.+?\) -->/$command_output/; }
Now, assuming that I call a subroutine that checks a user's username and password, then logs them in, I want to be able to return cookie information (or refresh information) back to this subroutine so that I can run further tests. I basically want to add a line for a cookie if a cookie variable is defined. And I want to be able to add a meta tag to my header if said variable is defined. I modified the code to the following, and it doesn't really seem to work (assume that I do define all these variables):
while ($HTML =~ /<!-- fillin\((.+?)\) -->/) { my $command_output = &{$templateCall->{$1}}; # a subroutine call ($HTML, $cookie, $refresh) =~ s/<!-- fillin\(.+?\) -->/$command_outp +ut/; }
I have no problem generating header information after this point, and just making sure that it prints the header first.
Any help would be appreciated.
--Coplan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Header data from arbitrary calls
by ajwans (Scribe) on Mar 05, 2002 at 05:34 UTC | |
by Coplan (Pilgrim) on Mar 05, 2002 at 19:19 UTC | |
|
Re: Header data from arbitrary calls
by ajwans (Scribe) on Mar 05, 2002 at 21:28 UTC |