Problems? Is your data what you think it is? | |
PerlMonks |
Re: Hash code bugby reasonablekeith (Deacon) |
on Apr 28, 2006 at 09:10 UTC ( [id://546218]=note: print w/replies, xml ) | Need Help?? |
firstly Secode, don't use $a or $b, they are special variables used by Perl in sorting routines/
secondly, also always use strict forces you to declare any new variables with my (or similar), so you'll avoid silly typos like thirdly, always quote your barewords (by default use strict forces to do this too). What I mean by this is do... If this seems petty, then look at the following. Without knowing that A is a subroutine you could be forgiven for think your output might be A. Save yourself, and the people who maintain your code, the effort and clear up this ambiguity and always "use strict" using warnings will give you handy hints, like when you use a variable but haven't defined a value for it yet. A lot of it's messages can be ignored, but they'll often give you hints to potential problems with your code. Applying all this to your script gives you... Which, when run, issues the warning "Useless use of hash element in void context at rja.pl line 12.", which might have been enough of a clue for you to figure this one out for yourself. Happy Coding!
--- my name's not Keith, and I'm not reasonable.
In Section
Seekers of Perl Wisdom
|
|