http://qs321.pair.com?node_id=11119088


in reply to Re: Perl::Critic says don't modify $_ in list functions and other things
in thread Perl::Critic says don't modify $_ in list functions and other things

my @list = map { s/\r\n$//; $_} <$fh>;

Would any line produced by evaluating the <$fh> expression ever end in \r\n? (This might happen if the file handle had been opened in binmode, but then there would only ever be a single "line" read from the handle and the list processing code would seem superfluous.)

I think s{ $/ \z }{}xms would work, but I also think that's an exact replacement for chomp; no improvement if so. If the /r modifier is available, s{ $/ \z }{}xmsr seems a very attractive alternative.


Give a man a fish:  <%-{-{-{-<