[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] STRING2LIST conversion



>Is there a function to load a @list with string's characters as elements:
>
>                @list= func("anystring");
>
>returns $list[0]="a", .... $list[9]="g" ???
>
>I read getc must be avoided (SLOW!) ...
>
>Luca.post

Hello,
      The following script works.

#!perl -w
$MyString = "werewolf";
@Ar = split (/ */,$MyString);
for $i (0 .. $#Ar) {
        print "ARRAY : $Ar[$i]\n";
}

Read the description of split on p.185 of the Camel.

Bob

__________________________________________________________
   Bob Wilkinson, Perl Programmer, Pindar plc
Tel: +44 (0)1904 613040    Email: B.Wilkinson@pindar.co.uk
Fax: +44 (0)1904 613110    URL: http://www.pindar.co.uk
__________________________________________________________