Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: strange map behavior

by CountZero (Bishop)
on Feb 25, 2008 at 19:36 UTC ( #670102=note: print w/replies, xml ) Need Help??

in reply to strange map behavior

Why are you trying to confuse Perl by adding useless double quotes? If you drop these double quotes, it works as expected: my %h = map { $_ => $_ } @arr ;

I have noticed recently that more monks have shown this tendency to add (double) quotes where it is not necessary and I wonder where they may have picked-up such a strange idea? Is there a new "Perl for Beginners Tutorial" running loose somewhere? If so, we need to catch it and have it shot.


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: strange map behavior
by revdiablo (Prior) on Feb 26, 2008 at 04:24 UTC
    I wonder where they may have picked-up such a strange idea?

    In this case, the quotes are a remnant of his fuller code (it's almost a case of "show us the real code, not an unrepresentative sample"), see Re^2: strange map behavior. But in many cases, the tendency to over-quote can be attributed to converted shell scripters. In Bourne shells (and probably many others), you need to quote your variables to have them remain discrete values -- otherwise spaces and other whitespace can break them up into multiple tokens.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-09-26 22:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found