Julian, > So if you have something that bit you in the past I would like to
hear about it. $ perl -Mstrict -Mwarnings -e 'my %hash=(A=>1, B=>2); print
$hash{shift}, "\n"' B
Use of uninitialized value $hash{"shift"} in print at -e line 1. Uninitialized?
B is 2! Perl, what are you thinking?
This bit me hard as it took a long time to figure out (actually a colleague did
). The "shift" is actually 'shift' not shift(). I wish there we an ultra
strict mode which does not allow bare words for hash keys. I now only use two
syntaxes for hash keys. Once bitten twice shy. $hash{'A'};$hash{$key}; Example,
of what I would do today. First, always shift/set variables at the start of
every script/sub with sane defaults. $ perl -Mstrict -Mwarnings -e 'my
$key=shift || "A"; my %hash=(A=>1, B=>2); print $hash{$key}, "\n"' B
2
Thanks,Mike mrdvt92 _______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/