You pass them in just like you're thinking, and in your script, you get them from the array @ARGV. Like so:
my $numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments.\n";
foreach my $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum]\n";
}
If you just want some values, you can just use the @ARGV array. But if you are looking for something more powerful in order to do some command line options processing, you should use Getopt::Long.
You pass them in just like you're thinking, and in your script, you get them from the array
@ARGV
. Like so:From here.
If you just want some values, you can just use the @ARGV array. But if you are looking for something more powerful in order to do some command line options processing, you should use Getopt::Long.
Alternatively, a sexier perlish way.....
my ($src, $dest) = @ARGV;
"Assumes" two values are passed. Extra code can verify the assumption is safe.