in reply to Can't divide by zero bug?
It was a typo. Instead of $testword should have been $testWord
Normally such typos are caught by the use strict pragma so that made me wonder why it did not pick this up here.
And then I saw that you declare two different lexical variables:
and a bit later (but still within the same scope)while (my $testWord = <$listWord>){ ...
main(my $testword);
Obviously, use strict did not complain as all variables are "properly" declared, but obviously it serves no purpose to hand a freshly minted (and therefore undef) lexical variable to a subroutine.
I saw that you did it again in
my($bigramSuccess, $distanceSuccess, ) = main(my $testword, $r +ightWord);
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|