Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: Perl Unpack Cobol Binary File and Fields

by dbarkho14 (Novice)
on May 04, 2020 at 20:02 UTC ( [id://11116450]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl Unpack Cobol Binary File and Fields
in thread Perl Unpack Cobol Binary File and Fields

Seems like unpack "N" is on the right track but I am supposed to get some records with 425 on them and I did not get any after processing the whole file. FIELD2 is supposed to be the year with 2019 as the value but I am not getting anything close to this. Maybe if you can see how to get 2019 in FIELD2 then all could fall into place. Thanks again for helping. I will keep looking.

  • Comment on Re^4: Perl Unpack Cobol Binary File and Fields

Replies are listed 'Best First'.
Re^5: Perl Unpack Cobol Binary File and Fields
by Corion (Patriarch) on May 04, 2020 at 20:15 UTC

    This suggests that every field is just 2 bytes wide and you have two dummy bytes at the start of your record. Because I get 2020 when I look at the next two bytes as a 16-bit word:

    my $data1 = unpack 'n', substr( $str, 2,2 ); my $data2 = unpack 'n', substr( $str, 4,2 );

    The data itself looks plausible but are you really sure that you are looking at the correct record?

      yes I was looking at the wrong record. Now that I am looking at the correct one, first rec has 431 and 2020 as expected. I should be able to take it from here. Thanks so much for help!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-23 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found