develooper Front page | perl.beginners | Postings from March 2002

string indexing

Thread Previous | Thread Next
bob ackerman
March 4, 2002 09:13
string indexing
Message ID:
I am used to indexing a string in other languages, so i would like to say
print $x[3];
and see 'd' printed, but, of course, this isn't correct in perl.

so i did
print $y[2],"\n";

and that's fine.

now, how do i do that without an intermediate array.
i want to say
print split(//,"abcd")[1],"\n";

but i get compilation error.

or is there some built-in way to index a string?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About