#!/usr/bin/perl open(FILE1, "file1.txt"); open(FILE2, "file2.txt"); my @file1lines; while() { chomp($_); push(@file1lines, $_); } while() { my $issame = 0; chomp($_); foreach $line(@file1lines) { if($line eq $_) { $issame = 1; } } if($issame = 1) { print("$_\n"); } }