http://www.perlmonks.org?node_id=396524

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to tell binary from text data (like the Unix file program). Right now I'm using
sub is_text { my $c = shift; my $cl = length($c); return 0 if ($cl == 0); my $t = $c; $t =~ tr/a-zA-Z0-9//cs; return ($cl - length($t)) < 100; }
which obviously has a lot of room for improvements. Is there a CPAN module for this kind of thing?