while (<>) { push(@array, $1) if m/^(\w+)\s+(?!Vet)\S/; } print @array;