$p = "This is a pattern test."; if ($p =~ /(\w?\s)/){ print "$1\n"; } if ($p =~ /(\w\s)/){ print "$1\n"; }