Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: map problem

by talexb (Canon)
on Mar 09, 2012 at 17:44 UTC ( #958759=note: print w/ replies, xml ) Need Help??


in reply to Re^2: map problem
in thread map problem

I like a modification of your middle suggestion best:

my %y = map { "prefix_".$_ => 1 } qw(a b c);
There's no need to put $_ inside quotes, only to have Perl do variable interpolation on that string. :)

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re^3: map problem
Select or Download Code
Re^4: map problem
by Marshall (Prior) on Mar 09, 2012 at 18:17 UTC
    That will work just fine and dandy as near as I can tell.
    GREAT! - understandable! (in terms of what it does).
    For something like this I would probably add a comment in the code for others as tip to why this "understandable thing" was needed. Not just for the future readers, but you may even forget "why" after a few years. That stuff has happened to me before! If the technique is so tricky that you had to think a lot about it, put in a comment.

    But, yes,  "prefix_".$_ => 1 is "easy on the eyes" (and the brain)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2014-09-02 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls