Hi all,
I have a file to disassemble and I'm thinking Perl might be the way forward.
Sample data:
0004$ADAM0002*330004%19770004$BOB 0002*430004%1967
There are 3 data types in here that I need to split into separate files. Each data type is prefixed by the record length as the length may vary (but doesn't in this example)
So ...
1st record type '$' is 0004 length so it's value is 'ADAM', 2nd record type is '*' which is 0002 length so it's value is '33' and so on.
The record types may not appear in this order also.
End desired result is 3 files looking like:
dollar.txt
ADAM
BOB
asterisk.txt
33
43
percent.txt
1977
1967
I'm a complete novice when it comes to Perl so some code to get me started or links to similar examples would be massively appreciated!
Cheers,
Monty
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.