foreach my $record (@files_to_process){ # $$record{data} is the way to reference data since array is an array of hash refs while(my $line = <$$record{data}>){ next if $line !~ /^06/; #if line isn't needed jump to next record my $line2 = <$$record{data}>; #get next line for in a way that it won't be retrieved next time through from $line chomp($line); chomp($line2); #now do some processing on those 2 lines and then continue loop }