Each char / letter --> array from string value
- From: umesh.perl@xxxxxxxxx (Umesh T G)
- Date: Wed, 28 Dec 2005 23:20:10 +0530
Hi List,
I need to put each letter from a string to an array.
I am doing it this way and it works. I wanna know if there is any other
better way to do this / a built-in function.
#! /usr/bin/perl
$srt ="123";
$sl = length $srt;
$val= join (':', split(/ */, $srt) );
@arr = split(/:/,$val);
foreach $i (@arr) {
print $i."\n";
}
This gives me
1
2
3
This works fine for me.
I want an alternative solution, if any.
TIA,
Cheers,
Umesh.
- Follow-Ups:
- Re: Each char / letter --> array from string value
- From: Paul Lalli
- Re: Each char / letter --> array from string value
- From: Chris Devers
- Re: Each char / letter --> array from string value
- From: Adriano Ferreira
- Re: Each char / letter --> array from string value
- Prev by Date: Re: Processing a web page (or looping over a multi line string)
- Next by Date: Re: Each char / letter --> array from string value
- Previous by thread: Processing a web page (or looping over a multi line string)
- Next by thread: Re: Each char / letter --> array from string value
- Index(es):
Relevant Pages
|