Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: your Perl bug Achilles heel

by GrandFather (Saint)
on Dec 05, 2008 at 01:06 UTC ( [id://728152]=note: print w/replies, xml ) Need Help??


in reply to your Perl bug Achilles heel

use strict; use warnings; my @products = ( {id => 'jam', quantity => 10}, {id => 'cream', quantity => 4}, ); mySub (user => 'Flibble', map {$_->{id} => $_->{quantity}} @products +); print "\n"; mySub (user => 'Flibble', (map {$_->{id} => $_->{quantity}} @products) +); sub mySub { my %params = @_; print "$_: $params{$_}\n" for keys %params; }

Prints:

cream: 4 user: Flibble jam: 10 cream: 4 user: Flibble jam: 10

and the difference is?


Perl's payment curve coincides with its learning curve.

Replies are listed 'Best First'.
Re^2: your Perl bug Achilles heel
by perrin (Chancellor) on Dec 05, 2008 at 02:39 UTC
    It's just a poor example. In my real code I was getting the wrong result from a map in a similar situation because the context was not what I expected.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (9)
As of 2024-03-28 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found