in reply to Header data from arbitrary calls

You probably want to do something more like

open (FILE, $file) or die ("Couldn't open $file: $!"); @HTML = <FILE>; for (@HTML) { s/<!-- fillin\((.+?)\) -->/&{$templateCall->{$1}}/eg; } splice (@HTML, 0, 0, @HEADERS); # this is a subroutine called by the templateCall to add # a header sub add_header { my $header = shift; unshift (@HEADERS, $header); }
So that the headers get added to the start of the HTML.

Replies are listed 'Best First'.
Re: Re: Header data from arbitrary calls
by Coplan (Pilgrim) on Mar 05, 2002 at 19:19 UTC
    I'm not sure I follow.

    The subroutine that my code is contained within is the part that generates the entire HTML file, based on the template with the additional information filled in. I can generate the header information after the rest of the body is generated, that really isn't the problem. The problem is that I'm trying to return both the HTML buffer to be returned by the templateCall, as well as some other information (like if a cookie is set, or the refresh page information). For example...if I were working without a template model, I would be doing things differently. The subroutine called by templateCall would have a return line like this:

    sub SomeTemplateCall { my $refresh = "http://www.scenespot.org"; my $cookie = "some random number"; my $buffer .= "<b>Stuff</b>"; return ($buffer, $cookie, $buffer); } # The subroutine that called it: sub templateParser { my ($HTML, $cookie, $buffer) = SomeTemplateCall(); # Header would then be generated utilizing $buffer, $cookie # $HTML would then be the rest of the damn website }

    Due to the nature of my script, I can't really do things that way, apprently. At least it doesn't seem to work as I showed above.

    --Coplan