in reply to regex vs split

Madfisherman, i think you are trying to create a template program... I think this is closer to what you are looking for.
open(TEMPLATE, "template.html") or die $!; my @xtemplate = <TEMPLATE>; close (TEMPLATE); my $xtemplate = join("", @xtemplate); # get these values from cgi or whereever $replace1 ="meep"; $replace2 = "narf"; # your markers @markers = ("TITLE", "STUFF"); # your replacement values, arrayisized (ITS A WORD I TELL YOU!) @replace = ($replace1, $replace2); for ($i=0; $i<@markers; $i++) { eval ("\$xtemplate =~ s/\\*\\*\\*\\*$markers[$i]\\*\\*\\*\\*/$repl +ace[$i]/g"); } # your formatted result print $xtemplate;

Replies are listed 'Best First'.
Re: Re: regex vs split
by dragonchild (Archbishop) on Aug 23, 2001 at 17:25 UTC
    You're a C programmer, aren't you?
    open(TEMPLATE, "template.html") or die $!; my $xtemplate = join '', <TEMPLATE>; close (TEMPLATE); # your markers my @markers = qw(TITLE STUFF); # your replacement values, arrayisized (ITS A WORD I TELL YOU!) my @replace = qw(meep narf); $xtemplate =~ s/\*{4}$markers[$_]\*{4}/$replace[$_]/g for (0 .. $#markers); # your formatted result print $xtemplate;

    ------
    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!