> I'm puzzled why "chomp" doesn't remove both newlines.
Because Perl's $INPUT_RECORD_SEPARATOR = $/ defaults to a newline (line mode). "perldoc perlvar" and search for INPUT_RECORD_SEPARATOR to learn all about it.
Setting $/ to '' should be okay, but I would probably localize it like this (or at least don't do it before the chomp) in case changing it globally has any negative effects on input parsing elsewhere in the code:
{
local $/; # Temporarily set to ''
chomp $cv; # Remove all newlines
}
> I'm puzzled why "chomp" doesn't remove both newlines.
Because Perl's $INPUT_ RECORD_ SEPARATOR = $/ defaults to a newline (line mode). "perldoc perlvar" and search for INPUT_RECORD_ SEPARATOR to learn all about it.
Setting $/ to '' should be okay, but I would probably localize it like this (or at least don't do it before the chomp) in case changing it globally has any negative effects on input parsing elsewhere in the code:
{
local $/; # Temporarily set to ''
chomp $cv; # Remove all newlines
}