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 );

In reply to Re: Re: Re: Remove field inside [ ] brackets by graff
in thread Remove field inside [ ] brackets by jamen_98

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.