> -----Original Message-----
> From: Shannon Murdoch [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 02, 2001 6:51 AM
> To: [EMAIL PROTECTED]
> Subject: Re: $variable manipulation question
> 
> 
> I found a solution not long after using a loop of sorts. (and 
> killed two
> birds with one stone, as my next step was to put each item 
> (space delimited)
> into an array).
> I made a loop saying, 'as long as $input still has characters 
> in it, put
> each one (one at a time) into the @front_chars array, then 
> reverse the list
> order so it's normal again.'
> 
> $input = "1234";
> 
> while($input ne undef){
> push(@front_chars,chop($input));
> }
> @front_chars = reverse @front_chars;
> 
> Not sure if this is helpful to anyone, but it helped me....

How did that help you? Now you have an array of individual
characters, gotten the hard way. Using split() is the way
to do this (see perldoc -f split):

   @chars = split //, $input;

To print this list out with spaces between, you can:

   $" = ' ';         # this is the default
   print "@chars";   # double quotes required here

or

   print join ' ', @chars;

The split and join can be combined to elminate the intermediate
array:

   print join ' ', split //, $input;

Which was brian's solution.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to