Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^5: Preferred technique for named subroutine parameters?

by akho (Hermit)
on May 22, 2009 at 21:09 UTC ( [id://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 (Archbishop) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://765754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found