in reply to How to split a string

Red_Dragon,
Is there a way in Perl to...

The answer to this question is almost always yes and there is almost always more than one way to do it. "There is more than one way to do it" is one of Perl's mottos. In this case, I will provide a straight forward answer.

my $str = '1029576843'; my @f = split //, $str; print $f[ 4 ]; # 5

Cheers - L~R

Using a different variable for each piece of the string would require symbolic references which is typically frowned on which is why I used an array

Replies are listed 'Best First'.
Re^2: How to split a string
by Ardemus (Beadle) on Jan 28, 2005 at 18:22 UTC
    I would suggest that there are valid reasons to use serial variables rather than (or in addition to) an array. RegEx is a good example, setting $1, $2, $3, etc.

    Ardemus "This, right now, is our lives."