[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] file testing



At 9:22 AM 09.01.96, Adam Weisser wrote:
>I was wondering if someone could tell me how MacPerl tells if a file is of
>type text. In other words, how does the -T file test operator work? I seem
>to be having inconsistent results...

According to the camel book:

        "The first block or so of the file is examined for odd
         characters such as strange control codes and metacharacters.
         If too many odd characters (> 10%) are found, it's a -B
         file, otherwise it's a -T file. Also, any file containing
         a null in the first block is considered a binary file ...
         Both -T and -B return true on a null file or a file at
         EOF when testing a filehandle."

This is more a heuristic than an algorithm, so there must be cases where it
breaks down.

                A

--
angus@aegypt.demon.co.uk  angus@pobox.com  http://www.tardis.ed.ac.uk/~angus/

    "If the times don't demand the best from you, invent other times."
        ["Baol: una tranquilla notte di regime", Stefano Benni]