The A and the Z are the file header and footer. Within the file header and footer there can be multiple transactions. The H and the S are the transaction header records for TL and LTL respectively. The C is the Carrier record, it occurs once per H or S, the L is the Location record, will have an L record for each pick-up and delivery location. The R, O, I and P records are the order records and can occur multiple times for each stop (L record). Below is an example of an ROI abc file.

1. The input file is abc.txt

2. Check file for TL header records (adds, deletes, modifies) identified by "HA", "HD" and "HM".

2a) Check Art file for the LTL header records (adds, deletes,modifies) identified by "SA" , "SD" and "SM".

3. For Adds, ("HA", "SA"), catch email value.(It should be in between "P" records (order R, O, I and P).

4. For Modifications, ("HM", "SM"), catch email value.(It should be in between "P" records (order R, O, I and P).

I would like to catch email address values before HATL or SALTL or HMTL or SMLTL or HDTL or SDLTL line starts...

I started writing like this ...

#!/usr/bin/perl open SEE ,"c:/abc.txt"; @ok=<SEE>; close(SEE); foreach(@ok) { if($_ =~ /HATL/) { ($o,$t) = split(/\s+/, $_); print "second value $t<br>"; ### I would like to catch email address values before HATL or SALTL li +ne starts... ### How can i do that? } if($_ =~ /SALTL/) { ($o,$t) = split(/\s+/, $_); print "second value $t<br>"; } }
Please try to provide a soln... Thanks

update (broquaint): added formatting + dropped customer data sample


In reply to catch values from txt file by Anonymous Monk

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.