in reply to Extracting records with unique ID
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.
|
|---|