Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: strange map behavior

by CountZero (Bishop)
on Feb 25, 2008 at 19:36 UTC ( [id://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.

CountZero

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found