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

Re: foreach (each character in string..)?

by robobunny (Friar)
on Jan 20, 2004 at 16:42 UTC ( #322629=note: print w/replies, xml ) Need Help??


in reply to foreach (each character in string..)?

OK, since I was late with my legit response, here's a stupid way:
my @list; my $string = "hi there"; while($string) { push @list, chop($string); } foreach(reverse(@list)) { print "$_\n"; }

Replies are listed 'Best First'.
Re: Re: foreach (each character in string..)?
by boo_radley (Parson) on Jan 20, 2004 at 17:57 UTC

    make it smart-stupid with unshift.
    really not adding anything,
    boo

      To be honest, I'm amazed no one has bitched because it fails if you hand it the string '0', but thanks anyway :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2023-12-11 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?