... my $name = "John Doe Joe"; # should match my $name = "John D"; # should match my $name = "John "; # should not match my $name = "John"; # should not match # Match only if after a space it find a letter if($name=~/[\s+.]+/) { @values = split /[\s+.]+/, $name; print "\n@values\n"; }else{ print "\n No spaces: $name\n"; } ...