#!/usr/bin/perl -w use strict; my %firstfile; open IN_A, ") { chomp; $firstfile{$_}++; } close IN_A; open IN_B, ") { chomp; print if exists($firstfile{$_}); } close IN_B;