in reply to Re^2: Strings mangled on printing
in thread Strings mangled on printing

Also note that $inp =~ s/\s+$//; will remove all trailing white space, including newlines (\n) and returns (\r).

Update: Correct typo (per reply).

Replies are listed 'Best First'.
Re^4: Strings mangled on printing
by sn1987a (Curate) on Jun 04, 2015 at 18:56 UTC

    Actually, $inp =~ s/\s$//; will remove only a single whitespace character at the end of the line.

    Use $inp =~ s/\s+$//; to remove all of them.