/^(?:\d{5,}|\D+)/ #### foreach (@stuff) { my $status = ( /^\d{5,}$/ ) ? 'valid' : 'invalid'; print "$_ is $status\n"; }