biohisham has asked for the wisdom of the Perl Monks concerning the following question:
Thanks Your Mother and citromatik, that was inspirational really...my actual question is actually like this::::
i want to print an array backward one element at a time using pop() and the the last index holder "$#array", but $#array just does not work properly when placed in a while(){} condition or a for(){},
suppose:
this code only prints (9 .. 5) but this code works just fine@array=(1,2,3,4,5,6,7,8,9); while($index < $#array+1){ $last=pop(@array); print "$last\n"; $index++; }
@array=(1,2,3,4,5,6,7,8,9); $end=($#array+1); while($index < $end){ $last=pop(@array); print "$last\n"; $index++; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: $#array issue
by Your Mother (Archbishop) on Jun 14, 2009 at 22:59 UTC | |
Re: $#array issue
by Your Mother (Archbishop) on Jun 14, 2009 at 23:21 UTC | |
Re: $#array issue
by citromatik (Curate) on Jun 14, 2009 at 23:01 UTC | |
by Your Mother (Archbishop) on Jun 14, 2009 at 23:14 UTC | |
Re: $#array issue
by shmem (Chancellor) on Jun 14, 2009 at 23:59 UTC | |
Re: $#array issue
by jwkrahn (Abbot) on Jun 14, 2009 at 23:32 UTC | |
Re: $#array issue
by JavaFan (Canon) on Jun 14, 2009 at 23:28 UTC | |
Re: $#array issue
by QM (Parson) on Jun 15, 2009 at 18:44 UTC | |
Re: $#array issue
by shmem (Chancellor) on Jun 15, 2009 at 00:05 UTC | |
by biohisham (Priest) on Jun 15, 2009 at 16:04 UTC |
Back to
Seekers of Perl Wisdom