At 17:08 -0800 01/02/2011, Kenneth Wolcott wrote:
how do make certain that no input (keyboard + mouse paste) is outside of 7-bit ASCII in a perl script?
The regular expression means that from the beginning to the end of the (chomped) input is either nothing or a string containing only characters 32 to 126.
#!/usr/local/bin/perl use strict; print "Type something (type 'q' to exit) -> "; while (<STDIN>){ chomp; print "Bye!" and last if /^q$/i; if ( /^[\040-\176]*$/ ){ # all from space to tilde print "OK. '$_' is all us-ascii\n-> " } else { print "Can't accept '$_' ; " . "contains non us-ascii characters\n-> " } } JD -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/