in reply to Is It Text-Editable???

That's a difficult call to make - a .jpg is editable with a graphics program like GIMP.

But if you mean if it's a text file or not, Perl can try to guess if you check the file with -B operator.Note that this is just a guess, and some text files might confuse it. In particular, I've never tried it with UTF or ISO-8859-X files.

Another option is to call the Unix file function, and parse it's output to see if it thought you were dealing with a text file.

Replies are listed 'Best First'.
Re: Re: Is It Text-Editable???
by sgifford (Prior) on Apr 27, 2004 at 20:19 UTC
    File::Magic is a more perlish way of finding a file's type. If you use the MIME version of this from File::MimeInfo::Magic, you can probably just see if the MIME type matches m|^text/|.

    Update: As davido says, File::Type may work too. It claims to solve many bugs in the two modules I suggested.