Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

Replies are listed 'Best First'.
Re^4: map problem
by Marshall (Abbot) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://958759]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2018-04-25 07:55 GMT
Find Nodes?
    Voting Booth?