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

Hi everyone, I am very new to pearl scripting. Actually i am having a doubt I am inserting some values into an array using the push command and i want to retrieve some of this values using the indexes. Is it possible? i.e, I am inserting var1, var2,var3,var4...var100 values into an array @list
push(@list,$var1); push(@list,$var2); push(@list,$var3); . . push(@list,$var100);
Now my question, is it possible to retrieve some of the elements from that array though indexes like list[5],list[10],list[15],list[25]?. I tried it, but in vain..please help me.

Replies are listed 'Best First'.
Re: Accesing the array elements via indexes which are inserted into it by push
by LanX (Saint) on Jan 08, 2013 at 07:14 UTC
    it's $list[5], because $ signals a scalar (i.e. singular) value you operate on. plz see perldata for details.

    please stop this try and error approach to Perl and try getting a good book/tutorial! =)

    Cheers Rolf

Re: Accesing the array elements via indexes which are inserted into it by push
by Anonymous Monk on Jan 08, 2013 at 07:41 UTC

    yes you can, but instead of list[5](which will end up in error) you need to treat it as a scalar $list[5]