Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: replace a string multiple times

by AnomalousMonk (Archbishop)
on Nov 15, 2014 at 09:31 UTC ( [id://1107296]=note: print w/replies, xml ) Need Help??


in reply to replace a string multiple times

Using join as others have suggested can give you better control of "inter-string separation", if you know what I mean, but you can do without it (and even without the  /e modifier):

c:\@Work\Perl>perl -wMstrict -le "my $s = 'int ant aunt'; print qq{'$s'}; ;; my $n = 3; $s =~ s{ (int) }{ qq{$1 } x $n }xmsge; print qq{'$s'}; ;; $s =~ s{ (ant \s+) }{$1$1}xmsg; print qq{'$s'}; " 'int ant aunt' 'int int int ant aunt' 'int int int ant ant aunt'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found