Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-19 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found