use strict; use warnings; use IO::Handle; my @files = qw(t1.txt t2.txt t3.txt); my @handles = (); for ( @files ) { push @handles, new IO::Handle; open $handles[-1], "<", $_ or die "cannot open $_!\n"; } while (1) { my @data; for my $handle ( @handles ) { my $line = <$handle>; exit unless defined $line; chomp $line; $line =~ /= ([^=]+)/; push @data, $1; } print "@data\n"; }