in reply to determing a binary file

Yes, use the  -B file test operator.

You can read the documentation on line.

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.

Replies are listed 'Best First'.
Re: Re: determing a binary file
by scholar (Acolyte) on Jan 14, 2003 at 18:51 UTC
    The -B file test operator makes it's best guess based on the file contents which in the absence of other contextual information (extensions, metatags, etc) is the best one can do to determine filetype. In theory all files are binary files and a (usually) better question to ask is whether a file is (not) a text file and therefore whether or not you can use tools with text-based assumptions on it. The only way to fully determine this is to read the entire file and test its contents against your assumptions. In practice though most programs either rely on meta-information, user input, or so-called "magic numbers" in certain filetypes.