Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Regex reset problem?

by c-era (Curate)
on Jul 07, 2000 at 18:29 UTC ( #21486=note: print w/replies, xml ) Need Help??


in reply to Regex reset problem?

That is because you didn't reset your $template, so your regex didn't match %%DESCRIPTION%%. Use can use a tmp variable to reset $template.
open (TEMPLATE, "<$template_file") or die "Can't open $template_file: +$!"; $template = do { local $/; <TEMPLATE> }; close TEMPLATE; $tmp_template = $template; #store the template opendir (BIN, "$prod_dir") or die "Can't open $dir: $!"; while (defined ($file = readdir BIN)) { next if ($file =~/^\.\.?$/); #skip file starting with period +s open (DESCR, "<$prod_dir/$file") or die "could not open $dir +/$file: $!"; $description = do { local $/; <DESCR> }; $template = $tmp_template; # restore the template $template =~ s/%%DESCRIPTION%%/$description/; open (OUTPUT, ">$output_directory/$file.html"); print OUTPUT $template; close OUTPUT; next; } closedir (BIN);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2020-10-24 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?