if( $s =~ m[^[ -~\t\n]+$] ) { print 'IsAscii'; } else { print 'IsNotAscii'; }