Parsing function args in Getopt::Long style
Is there a module to parse named function parameters in Getopt::Long style?
What I have in mind is something like:
# Call function
&foo('-p1' -> $v1, '-p2' => $v2);
#Define function
sub foo {
my $options = PARSER( [at] _);
my $v1 = $options->{'p1'};
# ....
}
Re: Parsing function args in Getopt::Long style
On Fri, 11 Jan 2008 13:11:23 -0800, Yuri Shtil wrote:
> Is there a module to parse named function parameters in Getopt::Long
> style?
>
> What I have in mind is something like:
>
> # Call function
> &foo('-p1' -> $v1, '-p2' => $v2);
>
> #Define function
> sub foo {
> my $options = PARSER( [at] _);
>
> my $v1 = $options->{'p1'};
>
> # ....
> }
Maybe something like this?
sub foo {
local [at] ARGV = [at] _;
$r = GetOptions(...);
...
}
M4
Re: Parsing function args in Getopt::Long style
"Yuri Shtil" <shtil [at] comcast.net> wrote:
> Is there a module to parse named function parameters in Getopt::Long
> style?
>
> What I have in mind is something like:
>
> # Call function
> &foo('-p1' -> $v1, '-p2' => $v2);
^ don't use & unless you know what it does.
foo( '-p1' => $v1, '-p2' => $b2 );
> #Define function
> sub foo {
> my $options = PARSER( [at] _);
my %options = [at] _;
> my $v1 = $options->{'p1'};
my $v1 = $options{ '-p1' );
--
John
http://johnbokma.com/perl/
Re: Parsing function args in Getopt::Long style
On Fri, 11 Jan 2008 13:11:23 -0800, Yuri Shtil wrote:
> Is there a module to parse named function parameters in Getopt::Long
> style?
>
> What I have in mind is something like:
>
> # Call function
> &foo('-p1' -> $v1, '-p2' => $v2);
>
> #Define function
> sub foo {
> my $options = PARSER( [at] _);
>
> my $v1 = $options->{'p1'};
>
> # ....
> }
Maybe something like this?
sub foo {
local [at] ARGV = [at] _;
$r = GetOptions(...);
...
}
M4
Re: Parsing function args in Getopt::Long style
"Yuri Shtil" <shtil [at] comcast.net> wrote:
> Is there a module to parse named function parameters in Getopt::Long
> style?
>
> What I have in mind is something like:
>
> # Call function
> &foo('-p1' -> $v1, '-p2' => $v2);
^ don't use & unless you know what it does.
foo( '-p1' => $v1, '-p2' => $b2 );
> #Define function
> sub foo {
> my $options = PARSER( [at] _);
my %options = [at] _;
> my $v1 = $options->{'p1'};
my $v1 = $options{ '-p1' );
--
John
http://johnbokma.com/perl/