Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: header footer

by Kenosis (Priest)
on Mar 04, 2014 at 22:34 UTC ( [id://1076990]=note: print w/replies, xml ) Need Help??


in reply to header footer

Can you share a (redacted, if necessary) copy of one of those records? Are the headers and footers the same for each record? Also, what separates those records?

Replies are listed 'Best First'.
Re^2: header footer
by gupr1980 (Acolyte) on Mar 04, 2014 at 22:47 UTC
    The file will have 1000s of records each record has its own header and footer. The header and footer can be different for each record. Only thing is that the header and footer are of fixed lenght 50 and 30.
    HDR.S287878877.DDDDD.DDDDDDXXXXXXXXXXXXXXXXXXXXXXX1STR HYTRES NAME PLA +CE DEST GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGG11111111111111111111122222222222222222222222222223 +33333333333333333333333333444444444444444444444444444444444455 5555555555555555555555555555566666666666666777777777777FTRDDDDDDDDDDFF +FFFFFFFFFFFFFFF HDR.S287878877.DDDDD.DDDDDDXXXXXXXXXXXXXXXXXXXXXXX1STR HYTRES NAME PLA +CE DEST GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGG11111111111111111111122222222222222222222222222223 +33333333333333333333333333444444444444444444444444444444444455 5555555555555555555555555555566666666666666777777777777FTRDDDDDDDDDDFF +FFFFFFFFFFFFFFF
    Sry if there was a better way to send a sample file. I copied the same record twice for simplicity sake but they will be different but leaght will be 50 and 30 and each record will have it until the end of the file.
      Just to clarify

      HDR.S287878877.DDDDD.DDDDDDXXXXXXXXXXXXXXXXXXXXXXX

      is the header and

      FTRDDDDDDDDDDFFFFFFFFFFFFFFFFF

      is the footer

        Give your dataset, here's one option:

        use strict; use warnings; local $/ = 'HDR'; while (<DATA>) { chomp; s/\n+$//; print substr( $_, 47, ( length $_ ) - 77 ), "\n" if /\S/; } __DATA__ HDR.S287878877.DDDDD.DDDDDDXXXXXXXXXXXXXXXXXXXXXXX1STR HYTRES NAME PLA +CE DEST GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGG11111111111111111111122222222222222222222222222223 +33333333333333333333333333444444444444444444444444444444444455 5555555555555555555555555555566666666666666777777777777FTRDDDDDDDDDDFF +FFFFFFFFFFFFFFF HDR.S287878877.DDDDD.DDDDDDXXXXXXXXXXXXXXXXXXXXXXX1STR HYTRES NAME PLA +CE DEST GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGG11111111111111111111122222222222222222222222222223 +33333333333333333333333333444444444444444444444444444444444455 5555555555555555555555555555566666666666666777777777777FTRDDDDDDDDDDFF +FFFFFFFFFFFFFFF

        Output:

        1STR HYTRES NAME PLACE DEST GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGG11111111111111111111122222222222222222222222222223 +33333333333333333333333333444444444444444444444444444444444455 5555555555555555555555555555566666666666666777777777777 1STR HYTRES NAME PLACE DEST GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGG11111111111111111111122222222222222222222222222223 +33333333333333333333333333444444444444444444444444444444444455 5555555555555555555555555555566666666666666777777777777

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1076990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found