Since you don't tell us what the output should be, I can only give you some general advice.
First, always do this:
use strict;
use warnings;
And declare your variables with my. It helps t catch common errors.
Secondly, you can replace your two outer loops with something as simple as
while (<>) {
# the current line is in $_,
# the current filename in $ARGV
}
Thirdly if you want to group data by the ID, store that data in a a hash keyed by the ID.
And finally there's the unpack function for extracting fixed width data, and perlpacktut contains a nice tutorial-style introduction on how to use it.
And really-finally: If your data format has a name, go to CPAN and search for it - maybe there's already a module that does most of your work.
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.