while () { chomp; print "'$_' contains ", (@{[/ /g]}) > 1 ? "more than one space.\n" : "either one space or none.\n"; } __DATA__ foo bar baz foobar foobar baz foo barbaz