[Pdx-pm] evil @ARGV syntax

chromatic chromatic at wgz.org
Tue Jul 19 11:10:55 PDT 2005


On Tue, 2005-07-19 at 11:05 -0700, Randall Hansen wrote:

>      if( $#ARGV + 1 < 1 || $#ARGV + 1 > 2 ) {

> i've tested this and found it to be true.  my question is, why on  
> earth would someone write this the first way?  it's one thing not to  
> understand scalar context; it seems entirely insane to add those ones  
> before the less|greater than tests.

My guess is a combination of not understanding scalar context and
copying code from a book that didn't understand scalar context.  ("To
find the length of an array, use $#ARRAY + 1.")

I once read a Perl book that suggested that being able to evaluate an
array in scalar context was a bug that a future version of Perl would,
hopefully, fix.

-- c



More information about the Pdx-pm-list mailing list