Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Problem in passing multiple argument through command line

by naikonta (Curate)
on Nov 14, 2007 at 02:10 UTC ( #650651=note: print w/ replies, xml ) Need Help??


in reply to Problem in passing multiple argument through command line

I prefer to use existing modules as shown by others. For simple options, however, I use the -s switch a lot.

$ 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!


Comment on Re: Problem in passing multiple argument through command line
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://650651]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2014-07-10 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (217 votes), past polls