Gossamer Forum
Home : General : Perl Programming :

Regular Expressions

Quote Reply
Regular Expressions
I have a subroutine that looks like this:


sub LoadTemplate {
my %template_tags = (
path => "/var/www/cgi-bin"
);

my $filename = shift;
my $text;

local $/;
local *F;

open(F, "< $filename\0");
$text = <F>;
close(F);

$text =~ s{ %% ( .*? ) %% }
{ exists($template_tags->{$1})
? $template_tags->{$1}
: ""
}gsex;
&PrintHeaders;
print $text;

}


I call the sub in this fashion LoadTemplate("templates/tags.html");

Now, it loads the template and prints the template correctly except that it does not replace the occurance of %%path%% which is in the tags.html file. It just strips it and leaves it blank.

The template file looks like this:
<html>
<head>
<title>Tags Test Page</title>
</head>
<body>
<font size="3">This the path: %%path%%</font>

</body>
</html>


Any help would be greatly appreciated.

Later,
Paul

http://www.fullmoonshining.com for Pearl Jam Fans
Subject Author Views Date
Thread Regular Expressions haplo 5667 Jun 12, 2001, 8:08 PM
Thread Re: Regular Expressions
Mark Badolato 5558 Jun 12, 2001, 8:33 PM
Thread Re: Regular Expressions
haplo 5552 Jun 12, 2001, 8:39 PM
Thread Re: Regular Expressions
Stealth 5558 Jun 12, 2001, 8:43 PM
Thread Re: Regular Expressions
haplo 5565 Jun 12, 2001, 8:59 PM
Thread Re: Regular Expressions
sponge 5557 Jun 12, 2001, 10:49 PM
Thread Re: Regular Expressions
Mark Badolato 5577 Jun 12, 2001, 11:23 PM
Thread Re: Regular Expressions
sponge 5538 Jun 12, 2001, 11:45 PM
Post Re: Regular Expressions
Alex 5530 Jun 13, 2001, 8:34 AM
Thread Re: Regular Expressions
haplo 5506 Jun 13, 2001, 1:46 PM
Post Re: Regular Expressions
sponge 5506 Jun 13, 2001, 3:57 PM