in reply to Re: Strange behavior with STDIN
in thread Strange behavior with STDIN

Thank you for the helpful response. I was using strict but not warnings; adding the latter uncovered a couple of minor issues unrelated to this.

Oddly what did work was adding two chops (not chomps).

chop $str; chop $str;

Odd because I've never run across this problem before.

As to why I'm interspersing \n and $/, well let's just call it lazy typing, sometimes one seems easier than the other. :-)

Thanks again.

Replies are listed 'Best First'.
Re^3: Strange behavior with STDIN
by ikegami (Patriarch) on Oct 26, 2021 at 19:26 UTC

    $str =~ s/\s+\z//; is a far better (and more portable) solution.