http://qs321.pair.com?node_id=728150

What's the most frequent type of bug you write when working in perl? These days, mine seems to be list context bugs. I try to do this:
ShoppingCart->new( user => $user, map { $_->id => $_->quantity } @products, );
But that really requires this:
ShoppingCart->new( user => $user, ( map { $_->id => $_->quantity } @products ), );
Contrived example, but hopefully you get the gist -- unexpected list context or lack of same is definitely a thorn in my side.

Anyone else have a class of errors that keeps biting them? Has it changed for you over your development as a Perl coder?

UPDATE

This was intended to be about the general question, not the example, but since people are complaining about the example, I'll offer one that works. CGI.pm will return undef or empty list for params with no value, depending on context. That means this code fails:

use CGI; use Data::Dumper; my $q = CGI->new(foo => 1); print Dumper [ foo => $q->param('foo'), bar => 1, ];
There are various ways to solve it, like forcing scalar context:
foo => scalar $q->param('foo'),
BTW, the thing I was thinking of with map was not context but the way that a function which takes a list can grab more than you meant it to of what follows:
ShoppingCart->new( user => $user, map { $_->id => $_->quantity } @products, bank_account => 99, );
Putting parentheses around the map solves the problem.