print join "\n", split "", "abcdefg";

split will give you a list where "abcdefg" is splitted on nothing.
so it will contain (a,b,c,d,e,f,g).
Join "\n" will join the items in the list with newlines between em.
So it will print:
a
b
c
d
e
f

If you want to reuse the array do this:

my @chars = split "", "abcdef";

if you want to reverse the characters use the reverse function. It reverse
items in a list.
so
print join "\n", reverse split "", "abcdefg";
will print
g
f
e
d
c
b
a

Good luck



----- Original Message -----
From: Ross Larner <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2001 8:28 PM
Subject: String deconstruction?


> Hello.  I am attempting to print a string one character at a time.  Right
now I am using one while loop with chop to create a new string, the reverse
of the original string, then another while loop with chop on the reversed
string to print out the characters.  I'm sure there's a more
straight-forward way of doing this - any ideas?
>
> Thanks,
> Ross
>

Reply via email to