use strict; use warnings; my ($handle, %hash, $a, $c); my $myfile = 'whatever.dat'; open $handle, $myfile; <$handle>; while ($_ = <$handle>) { $a = substr($_, 6, 1); $c = substr(<$handle>, 10, 1); <$handle> for (0..4); $hash{$c} = $a; }