MKJ747 has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I am using Getopt::Long to process command line arguments. For a string option, I would like to call a function and then process that value. I'm not sure how the value itself is captured for use in the function. Here's a simple example:
use strict; use Getopt::Long; my $result = GetOptions ( "c=s" => \&COMPTO, '<>' => sub {print "\nThat is not a valid parameter\n";}, ); sub COMPTO {print "\nGenerate Output for <some string> \n";}
In the example above, I run "program.pl -c <some string>", and I would to capture the string "<some string>" so I can use that value in the function COMPTO that is called. The Getopts::Long documentation implies you can do this, but I'm not sure of the syntax. Thank you.
|
|---|