#!/usr/bin/perl -w
use strict;
if (!@ARGV) {showhelp()}
else {
my $single = shift;
my $remain = join( ' ', @ARGV );
print "First arg = $single\n";
print "Remaining = $remain\n";
}
sub showhelp{
print <<"_HELP";
Trying to understand how Perl handles arguments
Use: $0 First Second Third Fourth ... Nth
Should output:
First arg = First
Remaining = Second Third Fourth ... Nth
The idea is to save the first argument to a scalar and the
remaining ones into a second scalar, with the space (and *only*
a space) being used as a separator.
_HELP
}
####
%perl arg1.pl fred barney wilma
First arg = fred
Remaining = barney wilma
####
%perl arg1.pl fred,barney wilma
First arg = fred
Remaining = barney wilma