perl -wle' my $string = "word\n"; print "string contains only word characters and nothing else" if $string =~ m/^\w+$/; ' string contains only word characters and nothing else