in reply to quick and safe way to deal with this?

This should work for any number of files, up to the maximum you can have open.

use List::Util qw( first ); my @files = ( 'FILE1', 'FILE2' ); my @handles; foreach my $file ( @files ) { open my $fh, '<', $file or die "Can't read $file: $!"; push @handles, $fh; } my $first_handle = shift @handles; while ( my $line = <$first_handle> ) { if ( defined first { $line ne <$_> } @handles ) { die "There's a difference."; } }