Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Preferred technique for named subroutine parameters?

by akho (Hermit)
on May 22, 2009 at 21:09 UTC ( #765754=note: print w/replies, xml ) Need Help??


in reply to Re^4: Preferred technique for named subroutine parameters?
in thread Preferred technique for named subroutine parameters?

Which is kinda useless if you're trying to pass this reference into a function.
  • Comment on Re^5: Preferred technique for named subroutine parameters?

Replies are listed 'Best First'.
Re^6: Preferred technique for named subroutine parameters?
by AnomalousMonk (Canon) on May 22, 2009 at 21:41 UTC
    Which is kinda useless if you're trying to pass this reference into a function.
    Well, if you're trying to pass a reference into a function and also have it be the name of an argument, yes.

    I wonder if you mean to pass a named parameter having a value that is a reference? Now, that seems to work pretty much as advertised:

    >perl -wMstrict -MData::Dumper -le "sub func { my %args = %{ $_[0] }; print Dumper \%args; print $args{foo}->{bar}; } func({ foo => { bar => 'baz' } }); " $VAR1 = { 'foo' => { 'bar' => 'baz' } }; baz

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://765754]
help
Chatterbox?
[Lady_Aleena]: marioroy, it has 3 subroutines which can be fed data to generate random things. See here.
[Lady_Aleena]: marioroy, it is used in 24 other modules I wrote.
[Lady_Aleena]: GUH! I wrote a script better than I thought! 8)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-05-29 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?