Oh, well, in that case, it's quite simple:
use constant HIGHEST_CHAR_ON_KBD => 126, #These values may differ for
+you, depending on where you bought
LOWEST_CHAR_ON_KBD => 9; # your keyboard. There are so
+me extra, non-keyboard chars in this range, as well.
while( <FILE> ) {
foreach( split("", $_) ) {
if( ( ord($_) > HIGHEST_CHAR_ON_KBD ) || ( ord($_) < LOWEST_CH
+AR_ON_KBD) ) {
say "It's a binary file";
last;
}
}
}
It isn't the best way of doing things, but it's a start.
Update: I completely forgot about spaces, tabs, carriage returns, and line feeds.
~
Thomas~
confess( "I offer no guarantees on my code." );