in reply to chomp - reference

Perhaps the value doesn't end in a newline, or perhaps someone changed $/. You can check what the values of $line and $/ using

use Data:::Dumper; { local $Data::Dumper::Useqq = 1; print(Dumper($var)); }

You might have better luck with the following:

$line =~ s/\s+\z//;
It removes all forms of whitespace from the end of the line (except NBSP U+00A0 in some circumstances).