use List::MoreUtils qw(each_arrayref); my @content = map { open(my $fh, '<', $_) or die $!; [<$fh>] } grep {-f} glob '*.csv' ; my $iterator = each_arrayref @content; while (my @file_lines = $iterator->()){ print @file_lines; }