>> On Tue, 17 Dec 2002 11:59:46, <[EMAIL PROTECTED]> said:

   > Also, you might change 'scalar(@url)' to '$#url' for simplicity.
       
More than just simplicity:

   void:chris~ % perl -le '@a=(5,10,15,20); print scalar @a,"\n",$#a'
   4
   3

$# signifies the index of the last element in an array - and since an
array is zero-indexed in Perl, that's always going to be one less than
the total number of elements in the array, which is what scalar(@array)
gives.  Using scalar(@array) as the upper bound in a for loop would give
an extra iteration of the for loop over a non-existant element with the
index $array[$#array+1].  So don't do that.  :-)

- Chris.
-- 
$a="printf.net";  Chris Ball | chris@void.$a | www.$a | finger: chris@$a
|  Q. How do you tell an extrovert techie from an introvert techie?
|  A. He looks at your feet rather than his own.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to