in reply to Check for Spaces in a String

use warnings; use strict; while (<DATA>) { if (/\w\s+\w/) { print "yes\n"; } else { print "no\n"; } } __DATA__ John Doe Joe John D John John

Outputs:

yes yes no no

Replies are listed 'Best First'.
Re^2: Check for Spaces in a String
by Anonymous Monk on Jun 15, 2015 at 18:29 UTC
    What about this:

    $name=~/\s+\w+/