Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Passing by Named Parameter

by jmanning2k (Pilgrim)
on Jan 28, 2004 at 18:07 UTC ( [id://324722]=note: print w/replies, xml ) Need Help??


in reply to Passing by Named Parameter

A really good example can be found in the Bio::Root::RootI module in BioPerl. See the _rearrange function.

This is a helper function used to sort out and make named parameters consistent. It's used as follows:

sub function { my $self = shift; my ($arg1, $arg2, $arg3) = $self->_rearrange([qw(NAME1 NAME2 NAME3)] +,@_); } function( '-name1' => 'value1', '-name2' => 'value2');
It simply avoids repeating the parsing, uppercasing, and dash removal in each function.

~J

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-16 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found