* Erik Price <[EMAIL PROTECTED]> [2002-11-21 22:20]:
> Or don't even bother with $#array since "$n <= @array" forces scalar
> context to the array, which causes it to interpolate to the number of
> elements.
> 
> Terser, quicker, more seductive.  Such is the way of the dark side of
> Perl programming.  (Even if by only one char.)

It's also (slightly) faster -- the value for $#array is stored in it's
own slot in the AV, which has to be filled in when $#array is
referenced, which it does by (effectively) doing scalar @array, but it's
not stored until it is asked for.

Also, note that 

  $n <= $#array

and 

  $i <= @array

are not equivalent:  @array == $#array + 1

(darren)

-- 
The Earth quakes and the heavens rattle; the beasts of nature flock
together and the nations of men flock apart; volcanoes usher up heat
while elsewhere water becomes ice and melts; and then on other days it
just rains.
    -- Principia Discordia
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to