open(FILE, $file) or die "$!"; my @file = ; close(FILE); foreach (@file) { if (m/$val[0]/) { $tmp = (split /\s+/,$_)[1]; print $tmp . "\n"; } }