Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^5: Bizarre Perl behavior?by LanX (Saint) |
on Jan 30, 2022 at 22:52 UTC ( [id://11140979]=note: print w/replies, xml ) | Need Help?? |
> There was \r\n at the end of every word in the array. I was using chomp and I should have been using something like $_ =~ s/\r[\n]*//; to remove it. Please note that chomp depends on $/, which is "\n" by default. But chomp's understanding of a so called logical "\n" is adjusted to the current OS. > > > I'm using Windows Subsystem for Linux Perl .. So because you were running the same data thru different OS, the "\r" wasn't always caught. Hence setting local $/ = "\x0D\x0A"; before chomping should solve your issue too.°
Cheers Rolf °) updated explicit "\x0D\x0A" because this logical "\n" is too confusing
In Section
Seekers of Perl Wisdom
|
|