Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

bgreenlee's scratchpad

by bgreenlee (Friar)
on Jul 13, 2004 at 09:07 UTC ( #373896=scratchpad: print w/ replies, xml ) Need Help??

Searching Backwards

Want to search backwards through a string, but don't want to have to reverse the string first? I had a need to do this recently in a golf problem ("reverse" is just too damn long). If you don't mind destroying your string, use s///:
$foo = '1 a 2 b 3 c'; while($foo =~ s/(\d)[\D]*$//) { print $1; } __output__ 321
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-07-31 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls