Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Wrap multiple programs

by Monk::Thomas (Friar)
on Mar 20, 2017 at 14:14 UTC ( [id://1185262]=note: print w/replies, xml ) Need Help??


in reply to Re: Wrap multiple programs
in thread Wrap multiple programs

For example, what if you want the --length option to default to 10 when plotting but to 20 when calculating?

Solution a) Leave value undefined for now. (use topic-specific default value when you branch into that code)

my $opt_length; GetOptions ( "length=i" => \$opt_length, ); # call plot() or calc() sub plot { my $length = opt_length // 10; ... } sub calc { my $length = opt_length // 20; ... }

Solution b) Only parse the first argument to decide which route to take and then hand over the rest of @ARGV to the next level -> http://perldoc.perl.org/Getopt/Long.html#Parsing-options-from-an-arbitrary-array

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-28 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found