in reply to command line arguments?
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 |