On 4/27/06, Dr.Ruud <[EMAIL PROTECTED]> wrote: > "Jay Savage" schreef: > > > for (0..#$arrayname) { print $array[$_] } > > The "#$" should be "$#" and you have two different array names there > that I assume you meant equal.
Not enough coffee this morning, I guess, but the point was to illustrate, not give working code. I think OP got it. > Alternative 1: > > print $ary[$_] for $[ .. $#ary; > I suppose it's an alternative, but why replace a constant with a variable if you don't have to? The only reason to do that would be if you messed with $[. Don't do that. Ever. Ever ever. At least not in any situation that's likely to get discussed on a beginners' list. > Alternative 2: > > print for @ary; > That's not really an alternative, because $_ is populated with the value of the current element of @ary. In the original example, it's populated with an integer. cf: my @array = qw/a b c d e f/; print "$_\n" for 0..$#array; print "$_\n" for @array; print "index $_ is $array[$_]\n" for 0..$#array; print "index $_ is $array[$_]\n" for @array; Have fun with that last one. Again, the point was to illustrate where $#array might be useful, not to play golf. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!