in reply to Re^2: List comparison problem
in thread List comparison problem
the first line isn't useful, because the second code line will remove all trailing white spaces, including the \r Windows CR character.
While I take your point, they are not entirely equivalent. The difference is that the first line removes all the \r characters wherever they appear in the line. The second does not do that.
use strict; use warnings; use Test::More tests => 2; my $have = "foo\rbar\rbaz\r\n"; my $want = "foobarbaz"; $have =~ s/\s+$//; isnt $have, $want, 'Not all carriage returns removed'; $have =~ s/\r//g; is $have, $want, 'All carriage returns removed';
I've spent far too much time over the years fighting poorly-formed, non-compliant, randomly-encoded data originating from Windows to assume anything about the quality of such data. YMMV.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: List comparison problem
by Laurent_R (Canon) on Aug 16, 2019 at 21:14 UTC | |
|
Re^4: List comparison problem
by perlmonkster (Initiate) on Aug 17, 2019 at 00:52 UTC |