chomp will not be enough to remove whitespace at the end of the line if your text file was created on a Windows machine (or with Windows line endings) and is then used on a Unix machine (or with Unix line endings). Use a regular expression to strip all whitespace from the end of the line(s):
$negWord =~ s/\s+$//;
In reply to Re^3: Comparing strings works in Windows but not Linux
by Corion
in thread Comparing strings works in Windows but not Linux
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |