Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(zdog) Re: Sequential Replacement

by zdog (Priest)
on Jul 09, 2002 at 17:53 UTC ( #180555=note: print w/ replies, xml ) Need Help??


in reply to Sequential Replacement

Here's a little different way of doing it that may give you some other ideas:

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


Comment on (zdog) Re: Sequential Replacement
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2015-07-07 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls