my $log1 = '/var/log/httpd/acce­ss_log'; my $log2 = '/var/log/httpd/acce­ss_log.1'; my %hash; open FH, $log1 or die $!; $hash{$_}++ while ; close FH; open FH, $log2 or die $!; while( ) { print if $hash{$_}; } close FH;