Perl Folks,Here's an interesting Perl-ism that bit me yesterday.  I've been 
starting to drop my sub "return" but I'm going back to being explicit as the 
performance hit has been fixed in later Perls and it just doesn't pay for 
itself in debugging.  Moral of the story: be explicit. I hope someone finds 
this helpful.Mike  perl -e '
use strict;
use warnings;
use Data::Dumper qw{Dumper};
our @list=(a=>1, b=>2);
sub a {{a=>1, b=>2}};   #{} is anon hash ref
sub b {[@list]};        #{} is anon array ref
sub c {{@list}};        #{} is block returns list
sub d {return {@list}}; #{} is anon hash refprint Dumper({a=>a(), b=>b(), 
c=>c(), d=>d()});
'
Odd number of elements in anonymous hash at -e line 11.
$VAR1 = {
          '1' => 'b',
          'c' => 'a',
          'a' => {
                   'a' => 1,
                   'b' => 2
                 },
          'b' => [
                   'a',
                   1,
                   'b',
                   2
                 ],
          'HASH(0x10b8b70)' => undef,
          '2' => 'd'
        };
 
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/

Reply via email to