in reply to Re: Re: Remove field inside [ ] brackets
in thread Remove field inside [ ] brackets
The file is output from another program...
Based on your evidence, I would guess that the other program runs on some other (non-Microsoft) OS, or else has some other reason for producing text with just "LF" instead of "CRLF" line termination. If you get to understand the nature of your input data better, you can get Perl to deal with it directly -- set the "$/" (input record separator) variable to match whatever that other program is using at the end of each line.
Perl is actually a useful tool for this sort of closer inspection of input data. Consider:
#!/usr/bin/perl use strict; $/ = undef; # go into "slurp" mode $_ = <>; # read whole file at once # (this assumes the file name is given in @ARGV) my @chars = split //; # each array element holds on character my $nlf = grep /\x0a/, @chars; my $ncr = grep /\x0d/, @chars; printf( "Input contained %d characters, %d line-feeds, %d carriage-ret +urns\n", scalar @chars, $nlf, $ncr );
|
|---|