in reply to Reading structured records from a file

If the file is small enough, then you can read it in all in one big array, and then use very easy array tools to do the rest of the work. This of course assumes that the same number of lines exist in each record.
my @keys = qw(dir name desc date box byte1 byte2 byte3 byte 4 ); my @loh; my @lines = <FILE>; # in array mode, read the entire file in one go while ( @lines ) { my %hash; @hash{ @keys } = splice @lines, 0, scalar @keys; push @loh, \%hash; shift @lines; #this is the CR line, now gone }

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Reading structured records from a file
by LukeyBoy (Friar) on Jan 18, 2002 at 08:14 UTC
    That's perfect, much nicer than the alternative! Thanks Masem!