Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: $ARGV dilemma

by blue_cowdawg (Monsignor)
on May 27, 2001 at 15:42 UTC ( [id://83592]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://83592]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found