#!/usr/bin/perl for $n (@ARGV) { $mods{$n} = $n } while () { chop; @a = split; $mods{$a[2]} && print "$_\n"; }