Hello Marshall,
This should do the work for you:
#!/usr/bin/perl use strict; use warnings; use feature 'say'; sub myChmop { my ($str) = @_; chomp $str; return $str; } sub myCrRemove { my ($str) = @_; $str =~ s/\r|\n//g; return $str; } my $str = "abcd\r\n"; my $chompReturn = myChmop($str); say "[$chompReturn]"; my $crRemoveReturn = myCrRemove($str); say "[$crRemoveReturn]"; __END__ $ perl test.pl ]abcd [abcd]
Also read this "similar question" Carrige Return and Line Feed in Perl..
Hope this helps, BR.
In reply to Re: Reading text file with <CR> line endings
by thanos1983
in thread Reading text file with <CR> line endings
by Marshall
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |