in reply to size of array

# define $#array @a = 1..5; print scalar @a, "\n"; $#a++ for 1..5; print scalar @a, "\n";


Replies are listed 'Best First'.
Re^2: size of array
by holli (Abbot) on May 04, 2005 at 13:50 UTC
    sh1tn, $#a++ for 1..5; is basically the same as
    for (1..5) { $#a=$_; }
    what makes no sense in my eyes. Why assigning 1..4 when you end up with 5 and do nothing in between?

    Anyway, here's mine:
    my @a = (0) x 5


    holli, /regexed monk/
      Yes, you are right holli.
      I ment to show what happens with each iteration.
      Everyone has the right to dislike my style.