Monks

I use AFPPARSER.EXE" /D from www.btbnet.de to convert AFP files to text. The following script to outputs
C:\test\perl>perl tle.pl ENVELOPEID 36 CUSTOMER_NAME 36 KUNDNAVN 36 ZIP_CODE 36 COUNTRY 36 FAKTURA 36 KONTRAKT 36 REGISTER 36 DATO 36
I would like the following script to output the text between the quotes following FQName together with the last quoted text between to 'TLE' elements:
ENVELOPEID 5172986 CUSTOMER_NAME Acme Inc KUNDNAVN BANANA AIRLINES ZIP_CODE SE-971 74 ..
The script:
use strict; use warnings; use 5.010; my $file; { local $/; $file = <DATA>; } while ($file =~ /TLE.*?FQName\W+'(.*?)'.*?'(.*?)'.*?(TLE)?/gs ) { say "$1 $2"; } __DATA__ .11893 ... TLE - Tag Logical Element 00033 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'ENVELOPEID' |Attribute Value Triplet 54 (x'36') |- '5172986' .11894 ... TLE - Tag Logical Element 00059 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'CUSTOMER_NAME' |Attribute Value Triplet 54 (x'36') |- 'Acme Inc' .11895 ... TLE - Tag Logical Element 00074 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'KUNDNAVN' |Attribute Value Triplet 54 (x'36') |- 'BANANA AIRLINES' .11896 ... TLE - Tag Logical Element 00033 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'ZIP_CODE' |Attribute Value Triplet 54 (x'36') |- 'SE-971 74' .11897 ... TLE - Tag Logical Element 00025 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'COUNTRY' |Attribute Value Triplet 54 (x'36') |- 'SE' .11898 ... TLE - Tag Logical Element 00030 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'FAKTURA' |Attribute Value Triplet 54 (x'36') |- '5643452' .11899 ... TLE - Tag Logical Element 00032 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'KONTRAKT' |Attribute Value Triplet 54 (x'36') |- '90234342' .11900 ... TLE - Tag Logical Element 00031 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'REGISTER' |Attribute Value Triplet 54 (x'36') |- 'AF89729' .11901 ... TLE - Tag Logical Element 00028 D3 +A090 00000 | |Fully Qualified Name Triplet 2 (x'02') |- Type 11 (x'0B') Attribute GID |- Format 0 (x'00') Character string |- FQName 'DATO' |Attribute Value Triplet 54 (x'36') |- '16.12.13'
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Multiline regexp question by andreas1234567

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.