#!/usr/bin/perl -w use strict; my @valid = grep { !/^[\w-]+:\s*\S+$/ } <>; # do some stuff with @valid