in reply to Understanding File Type

I usually use a module such as File::MMagic.