Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: /g option not making s// find all matches

by jwkrahn (Monsignor)
on May 28, 2018 at 08:23 UTC ( #1215298=note: print w/replies, xml ) Need Help??


in reply to /g option not making s// find all matches

As you have figured out the problem is not with the \K anchor, it is with the ^ (match only at beginning of line) anchor.

You can fix that with something like this:

while (<DATA>) { 1 while s/^ ~ .*? \K _ /+/x; print "$_"; }

Or perhaps something like this:

while (<DATA>) { s/^ ~ .*? \K ( .+ ) / ( my $x = $1 ) =~ tr-_-+-; $x /xe; print "$_"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-11-20 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (231 votes). Check out past polls.

    Notices?