in reply to $ARGV dilemma

Check out the following:

--$ cat argvtest.pl #!/usr/bin/perl -w ################################################################### use strict; print "too few$/" if scalar(@ARGV) < 3 ; print "just right$/" if scalar(@ARGV) == 3; print "too many$/" if scalar(@ARGV) > 3; --$ perl argvtest.pl 1 2 too few --$ perl argvtest.pl 1 2 3 just right --$ perl argvtest.pl 1 2 3 4 too many --$

scalar is your friend! ;-)
HTH


Peter L. BergholdSchooner Technology Consulting, Inc.
Peter@Berghold.Netwww.berghold.net

Replies are listed 'Best First'.
Re: Re: $ARGV dilemma
by blakem (Monsignor) on May 27, 2001 at 16:47 UTC
    Doesn't numeric comparison already put it in scalar context? i.e. isn't
    print "too few$/" if scalar(@ARGV) < 3;
    Equivalent to:
    print "too few$/" if @ARGV < 3;

      While I can't show you an example: I have seen numeric comparisons not work. Wish I could remember where it happened but it was a while ago...


      Peter L. BergholdSchooner Technology Consulting, Inc.
      Peter@Berghold.Netwww.berghold.net