Click here to get back home

Parsing function args in Getopt::Long style

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Parsing function args in Getopt::Long style Yuri Shtil 01-11-2008
Posted by Yuri Shtil on January 11, 2008, 4:11 pm
Please log in for more thread options
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(@_);

my $v1 = $options->;

# ....
}



Posted by Martijn Lievaart on January 11, 2008, 4:40 pm
Please log in for more thread options
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(@_);
>
> my $v1 = $options->;
>
> # ....
> }

Maybe something like this?

sub foo {
local @ARGV = @_;
$r = GetOptions(...);
...
}

M4

Posted by John Bokma on January 11, 2008, 6:03 pm
Please log in for more thread options

> 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(@_);


my %options = @_;

> my $v1 = $options->;

my $v1 = $options{ '-p1' );


--
John

http://johnbokma.com/perl/

Similar ThreadsPosted
Version? of getopt::Long October 4, 2004, 2:48 pm
Getopt::Long install problems October 4, 2004, 6:33 pm
module to convert wiki-style to html June 16, 2005, 3:09 pm
Module setup style and BEGIN blocks May 7, 2006, 8:53 pm
Sort::Maker: style => 'plain' difficulty December 14, 2006, 4:35 am
How to write Delphi 2005 XML-style project files (.bdsproj)? February 23, 2005, 10:48 am
XML::Sax::Writer build error (long data) August 2, 2005, 6:54 am
PARI stack overflow during long Net::SFTP connection July 16, 2004, 3:20 am
named arguments to XS function? March 24, 2006, 2:44 pm
XML::XPath delete function November 26, 2007, 3:35 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap