Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Look behind and global

by Tanktalus (Canon)
on Mar 14, 2005 at 15:31 UTC ( [id://439307]=note: print w/replies, xml ) Need Help??


in reply to Look behind and global

The only nice thing about zero-width assertions is that you don't have to capture anything. So, in that spirit, and in the spirit of TMTOWTDI, and in the spirit that this is what you were asking about (whether it's the best way to do it or not):

$ perl -e '$x=12345; $x=~s/(?<=\G\d{2})/\012/g; print $x,$/' 12 34 5
As you can see - I just added the \G to the assertion. Of course, if you start using anything other than numbers in there, I'm sure this could get all mucked up:
$ perl -e '$x="123d45"; $x=~s/(?<=\G\d{2})/\012/g; print $x,$/' 12 3d45

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found