in reply to Can't divide by zero bug?

First of all, you are using Switch.pm, which you should avoid! Switch introduces very hard to track down errors - avoid it! If you are using Perl 5.10, use the given .. when construct, otherwise, use cascaded if statements.

As to your division by zero, just in the case that it is not caused by Switch.pm, I only see one division in your code. Just guard that division and output more diagnostics when you encounter the case that the divisor is zero:

my $divisor = (@pairs + length($dictionWord)-1); die "Uhoh - cannot divide by zero. List of pairs is '@pairs' and d +ictionWord is '$dictionWord'." my $bigramCoef = 2 * $matches / $divisor;