Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: how to access the commandline arguments?

by crabbdean (Pilgrim)
on May 01, 2004 at 09:42 UTC ( #349590=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $count = @ARGV;
    print $count;
    
  2. or download this
    if (@ARGV < 3) {
            die "use: script var1 var2 var3\n";
    ...
            my ($var1, $var2, $var3) = @ARGV;
    }
    ## then use $var1, $var2 and $var3 in your program
    
  3. or download this
    my ($stream, $path, $rturn, $depth, $display) = @ARGV;
    $stream = \*STDOUT unless @_ > 0;
    ...
    $rturn = 'all' unless @_ > 2;
    $depth = -1 unless @_ > 3;
    $display = 'rel_file' unless @_ > 4;
    
  4. or download this
    my $nextvar = shift @ARGV;
    
  5. or download this
    for my $this (@ARGV) {
           print "$this\n";
    }
    
  6. or download this
    while (<>) {
               print "$_\n";
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-07-07 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls