foreach(@a){ $temp = $_; $test = grep($temp eq $_,@b); print "$test\n"; }