my @keys = qw(dir name desc date box byte1 byte2 byte3 byte 4 ); my @loh; my @lines = ; # 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 }