Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Read a variable backwards..

by johngg (Abbot)
on Jan 06, 2014 at 13:03 UTC ( #1069507=note: print w/ replies, xml ) Need Help??


in reply to Read a variable backwards..

You could use chop if you don't need to retain the string.

$ perl -E ' $str = q{abcdefg}; say chop $str while $str;' g f e d c b a $

I hope this is helpful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Read a variable backwards..
by moritz (Cardinal) on Jan 06, 2014 at 18:32 UTC
Re^2: Read a variable backwards..
by littlemonk (Sexton) on Jan 06, 2014 at 16:18 UTC

    check this code

    $str="123456789"; @arr=split(//,$str); while($tmp=pop(@arr)){ print "\nfirst-frm last-->$tmp"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2016-06-27 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (336 votes). Check out past polls.