use strict; use warnings; open my $first_file, '<', '/my/first/file'; open my $second_file, '<', '/my/second/file'; while (my $line_first = <$first_file>) { my $line_second = <$second_file>; # do something with $line_first and $line_second # ... }