Duh v D'oh

Eden Cardim edencardim at gmail.com
Fri Nov 7 12:45:34 GMT 2008


On Thu, Nov 6, 2008 at 1:33 PM, Paul Makepeace <paulm at paulm.com> wrote:
> Following on the theme from a conversation with Mark at Dim Sum today*, spot
> the mistake I just wasted an hour on,
>
>  my $publication_stats = [['Source', 'ID Publication', 'Article count']];
>  foreach my $given_source (%publication_map_by_name) {
>    push @$publication_stats, [$given_source,
>                               $publication_map_by_name{$given_source},
>                               $article_count_by_source{$given_source}];
>  }
>
> If it's not staring out at you, you're possibly also a python programmer.
> Python here arguably DWIM better than perl.
>
> Paul
>
> * there's some mistakes where you at the end go "D'oh!" because perl is
> messing you around with its weirdness or otherwise non-intuitive behavior.
> "Duh" when you're messing around and just not paying attention.

I wouldn't call that non-intuitive, it's a matter of culture. Perl
coders are used to being verbose about whether they want keys/values
from a hash. If someone changed the behavior to make a hash in list
context return it's keys, you would confuse a lot of Perl programmers
out there too.  And I'm particularly fond of perl's behaviour because
it allows interesting cookbook tricks such as

%config = (%default, %user_provided)

-- 
   Eden Cardim       Need help with your Catalyst or DBIx::Class project?
  Code Monkey                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/            http://www.shadowcat.co.uk/servers/


More information about the london.pm mailing list