use strict; use warnings; my @array = qw (zero one two); my $str = "blah ##REP0## blah ##REP1##\nblah ##REP2##\n"; $str =~ s/##REP(\d+?)##/$array[$1]/g; print $str;
Update: Another idea is to replace the ##*##'s with %s and do:
$str = sprintf ($str, @array);
Just a thought ...
Zenon Zabinski | zdog | zdog@perlmonk.org
In reply to (zdog) Re: Sequential Replacement
by zdog
in thread Sequential Replacement
by cidaris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |