rammohan has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: How to access each element in an array Perl
by choroba (Cardinal) on Jan 18, 2014 at 09:45 UTC
    Perl is not C. A string in Perl is not an array of characters.

    Your array only has one member.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: How to access each element in an array Perl
by 2teez (Vicar) on Jan 18, 2014 at 12:40 UTC

    ...How to do this please let me know.
    How would you do it? How do I post a question effectively? might also do.
    Howbeit, to give a headup doing thus is one way of getting your desired output:

    my @arr = qw(Larrywall); print substr( $arr[0], index( $arr[0], q[y] ), 1 );
    Please check index and substr. Also please note what choroba said.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re: How to access each element in an array Perl
by Anonymous Monk on Jan 18, 2014 at 08:26 UTC

      Try this

      my@arr=qw( Larrywall); print "\n @arr[0]"; $string=@arr[0]; $sub_str1=substr($string,0,4); $sub_str2=substr($string,5,2); print "\n $sub_str1"; print "\n $sub_str2";
Re: How to access each element in an array Perl
by elTriberium (Friar) on Jan 18, 2014 at 18:31 UTC

    Adding to the other comments if you really want to make this an array then use spaces between the letters, this is the delimiter for "qw" elements:

    my @array = qw(L a r r y W a l l);
      Why not:
      use Data::Dump; my $string = 'LarryWall'; my @array = split//, $string; dd @array;

      (Data::Dump is just to show what's in the array)

      Here's a oneliner doing the same thing

      perl -MData::Dump -e 'my $str = 'LarryWall'; my @arr = split//,$str; d +d @arr;'