Assign Named $foo and $bar - Fortune [possible satire]

LeoNerdI feel there must be a way to do this... given func( foo => 1, bar => 2 ); how to write my ( $foo, $bar ) = .... inside the function?
LeoNerdMy current attempt is my ( $foo, $bar ) = @{{@_}}{qw( foo bar )}; which is messy as sin
ickeLeoNerd: what's the problem? readability?
LeoNerdYeah
dazjorzLeoNerd: I'd change specs to be func({ foo => 1, bar => 2})
dazjorzthen my ($foo, $bar) = ($_[0]{foo}, $_[0]{bar});
tonLeoNerd: If you insist on doing it on one line, that's about as good as it gets. But why not use a temporary hash ? Should be just as fast and as readable
LeoNerdHrm.. :/ Then it's only marginally nicer as my ( $foo, $bar ) = @{$_[0]}{qw( foo bar )};
LeoNerdmy %args = @_; my ( $foo, $bar ) = @args{qw( foo bar )}; yeah... that works
mstLeoNerd: my ($foo, $bar) = do { my %a = @_; @a{qw(foo bar)} };
tonif you combine it with a delete you can then check if %args is empty and catch typos or unexpected arguments....
LeoNerdOooh.. a do block
vincentor use padwalker
LeoNerdOh, args won't be empty... this is a wrapper function that pulls a few named args off and sends the rest to a nested inner function
LeoNerdNow.. I want to call a function "foreach" but that breaks things... suggestions?
ickea method could be named 'foreach'
LeoNerdYeah... but this is a plain function
icketough
LeoNerdI suppose "iterate" is about as best as I'll get
ickefor_each
tonLeoNerd: forall ?
LeoNerdI'll think on it overnight maybe.. I guess it's home time now
ickeforeachandeverysingleone
tonforever, forfun, forlorn...
vincentFOREACH
ickeboo
LeoNerdone_for $all and $all for @one;
rindolfforevery?
rindolf<LeoNerd> one_for $all and $all for @one; - heh
rindolf$one for @all and @all for @one
rindolf$one for @all and @all for @$one
rindolf$one for @all and @all for $one
rindolfWorks too.
LeoNerdHrm.. it does?
LeoNerddeparse: $one for @all and @all for $one
buubotLeoNerd: Error: syntax error at (eval 107195) line 1, near "@all for "
LeoNerdYou can't use two postmod fors in a single statement
Channel#perl
NetworkFreenode
TaglineSyntax Fun
Published2009-12-14