in reply to Problem in passing multiple argument through command line
$ cat clo.pl #!/usr/bin/perl -s use strict; use warnings; use vars qw($company $location); $company ||= 'NO_COMPANY'; $location ||= 'NO_LOCATION'; printf "The %s company is located at $location\n", $company, $location; $ ./clo.pl The NO_COMPANY company is located at NO_LOCATION $ ./clo.pl -company='Grant Alpho System' The Grant Alpho System company is located at NO_LOCATION $ ./clo.pl -company='Grant Alpho System' -location=TheOtherGlobe The Grant Alpho System company is located at TheOtherGlobe
Or, if you only want to read a location with more customers, you can read from @ARGV yourself.
$ cat report.pl #!/usr/bin/perl use strict; use warnings; my($location, @customers) = @ARGV; die "Can't create report, no customer defined\n" unless @customers; print "The following customers are located at $location\n"; my $i; for (@customers) { print ++$i, ". $_\n"; } $ ./report.pl Can't create report, no customer defined $ ./report.pl NY Penelope Abraham Marie 'John Doe' The following customers are located at NY 1. Penelope 2. Abraham 3. Marie 4. John Doe
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
|
|---|