in reply to Re: testing if a string is ascii (^)
in thread testing if a string is ascii

Actually, I think the better way would be to return true on the first non-ASCII character, and treat "true" as the condition to be avoided:
sub nonascii { local $_ = shift; /[^\0-\x7f]/; # or /[^[:ascii:]]/ } for my $test ( split( " ", "foo bar b\xe1 baz" )) { next if ( nonascii( $test )); print "$test\n"; }
(update: this is just a stylistic difference relative to  $str !~ /[^\0-\x7f]/ -- to avoid the cognitive challenge of the double-negative)