Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Perl Idioms Explained - my ($foo, $bar) = @{shift(@_)}{qw/ -foo -bar /}

by Roger (Parson)
on Mar 01, 2004 at 22:43 UTC ( #333084=note: print w/replies, xml ) Need Help??


in reply to Re: Perl Idioms Explained - my ($foo, $bar) = @{shift(@_)}{qw/ -foo -bar /}
in thread Perl Idioms Explained - my ($foo, $bar) = @{shift(@_)}{qw/ -foo -bar /}

I would agree with you that this is not the best approach and I don't use it in my code anyway. Yesterday someone asked in the CB about what the following code is doing:
my ($foo, $bar) = @{+shift}{qw/ -foo -bar/};

I thought it might be a good idea to post it. It's not that obvious to the less experienced coders that the hash slice @values = @hash{@keys} is involved. There was a supersticious '+' in the original question as well, which I have removed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://333084]
help
Chatterbox?
[LanX]: I think I've send one whitespace by myself at 20
[Discipulus]: are you polluting tests? grin..
[LanX]: 123456789012345678 901234567890123456 789012345678901234 567890
[LanX]: yep
[LanX]: 1234567890 1234567890 1234567890
[LanX]: so inserting own whitespace helps, ie. a JS warning on submit could help preventing problems

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-07-24 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (350 votes). Check out past polls.