#!/usr/bin/env perl use 5.010; use strict; use warnings; my @s = ('John', 'John ', 'John Doe', 'John P. Doe'); # last 2 should match for (@s){ my @v = split /\s+\b/; # split on whitespace followed by a word boundary if(@v > 1 ){ # if the split did any splitting say; # do stuff with the line or elements } }