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.