Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: command line switches (array)

by mjscott2702 (Pilgrim)
on Nov 01, 2010 at 17:01 UTC ( #868811=note: print w/ replies, xml ) Need Help??


in reply to command line switches (array)

If you really can't use any modules, even a core one that ships with Perl itself (and you should ask why not, if that is the case), then simply scan over the @ARGV array and take appropriate actions, something like (untested):

for (my $i=; $i < @ARGV; $i++)) { if ($ARGV[$i] eq "-l") { warn "Logfile $ARGV[$i+1] missing\n" unless -e $ARGV[$i+1]; } elsif ($ARGV[$i] eq "-u") { warn "Useraccounts $ARGV[$i+1] missing\n" unless -e $ARGV[$i+1]; } else { warn "Invalid switch $ARGV[$i]\n"; } $i++; }


Comment on Re: command line switches (array)
Download Code
Re^2: command line switches (array)
by Corion (Pope) on Nov 01, 2010 at 17:09 UTC

    The above will result in weird behaviour if you have a user named -l or a logfile named -u :-)))

      yeah the logfile name and the useraccounts name will always be the same. Infact it should test for the existance of them.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2015-07-06 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (80 votes), past polls