in reply to command line arguments?

There are several ways to do this.

For very simple uses you can simply shift the values one at a time of the @ARGV array. This is very easy to do for short throw-away applications, but becomes an unmanagable mess for anything more complex. For example:

#!/usr/bin/perl my $argument_1 = shift; die "Invalid input" unless $argument_1;

A better approach is to use one of the many Getopt modules. I think that both Getopt::std and Getopt::Long have both been part of the core Perl for some time, so you should have them on your system already.

For example:

#!/usr/bin/perl use Getopt::Std; getopt('oDI'); print "\nOption o = $opt_o";

You should find that perldoc will give you the full details of both modules, and any additional ones you install.

Replies are listed 'Best First'.
Re: Re: command line arguments?
by redemption (Sexton) on May 23, 2002 at 09:24 UTC
    ok thanks guys... turns out a simple shift and some error-checking was enough... i'm not that advanced into perl to take a look at modules yet but thanks all the same dave, ajt... i was only looking for a quick solution since the core of the script is going to be a tough one (so expect more questions from me :-))... at least it's a comfort to know that there are modules to handle this for more complicated arguments

    cheers!