SPUG: Too long to find bug: Fat comma and assignment look similar, and have some similar meaning

Michael R. Wolf michaelrwolf at att.net
Thu Jan 14 09:07:02 PST 2010

This (distillation of a bug) took me way too long to notice,  
especially since it compiled OK without a warning.

     use warnings;
     use strict;

     my $x => rand;
     die 'Did you notice fat comma instead of assignment? Variable did  
not get set' unless defined $x;

In retrospect, what had me miss it was:
   1 - the visual similarity between '=' and '=>'
   2 - the similarity of meaning between "gets" (assignment) and "gets  
associated with" (fat comma's common use in creating hash key/value  

Can you think of a good use of fat comma (or skinny comma, for that  
matter) in this context?  Or, framed differently, why shouldn't (or  
can't) it get a warning like "Strange mixture of declaration,  
stringification, and function call in void context"?

Michael R. Wolf
     All mammals learn by playing!
         MichaelRWolf at att.net

More information about the spug-list mailing list