foreach my $line (@record) { ($timestamp, $current_time, $funds, $action, $current_funds) = split "\t",$line; # The values of $timestamp, $current_time, $funds, $action, $current_funds never change in this while loop. while ($count < 10){ $member{$timestamp} = [$current_time, $funds, $action, $current_funds]; $count += 1; } } #### for my $line (@record[0..9]) { ($timestamp, $current_time, $funds, $action, $current_funds) = split "\t",$line; $member{$timestamp} = [$current_time, $funds, $action, $current_funds]; }