I downloaded "Free Hex Editor Neo" and I saw that the lines seem to end (or start?) with two dots ".." whose hex values are "0d 0a". These are not visible when the file is opened normally. I don't know if this helps.

Here is two full lines of actual text from the file which denotes the end of one section and the beginning of the next. It was probably unnecessary but I replaced the dollar figures with nines:

CAS*CO*999*999.99~ LX*2~

A line with the "00003" string.:

SVC*HC:00003*999.99*999.9**1~

At the moment I have the following code in a file named test_script.pl, which gets me the first 14 lines and the regex one-liner match gets me the last three:

use warnings; use strict; #Note that this script throws errors when pull file paths are defined. #Must be run from the path that the input/output files exist. open my $fhi, '<', 'cr835.txt' or die "$!"; open my $fho, '>', 'cr_output.txt' or die "$!"; #Prints the first 14 lines to the output file while(<$fhi>) { 1 .. 14 ? print : last; } close $fhi; close $fho; system( q(perl -nle "print if /SE\Q*\E3841/ .. /IEA\Q*\E/" "cr835.txt" +) );

I hope that the difficulty we have had wasn't caused by my leaving something important out of my initial post.


In reply to Re^5: Matching range of text with another string in between by periodicalcoder
in thread Matching range of text with another string in between by periodicalcoder

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.