Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Using Magic Numbers

by kilinrax (Deacon)
on May 07, 2003 at 15:59 UTC ( #256272=note: print w/replies, xml ) Need Help??

in reply to Using Magic Numbers

There's always the unix utility 'file', which unfortunately doesn't seem to have a CPAN equivalent (unlike quite a few other unix file utilities). Maybe this is something worthy of consideration?

Update: I thought one didn't exist, having never encountered one, none turning up on a CPAN search, and none being registered in the File:: namespace. Obviously, I was wrong. Use File::MMagic as artist suggests ;)

Replies are listed 'Best First'.
Re: Using Magic Numbers
by Abigail-II (Bishop) on May 07, 2003 at 19:31 UTC
    IIRC, Dominus wrote a Perl implementation of "file" for Tom's "Perl Power Tools" project. If I were to ever do what the OP is doing, I'd settle for `file $file`, and modifying /etc/magic if needed.


Re: Re: Using Magic Numbers
by HamNRye (Monk) on May 07, 2003 at 16:08 UTC

    I should mention this will be on Windows, not the annointed Unix which sprung from the womb of the virgins fully formed.

    Artist, looks like File::MMagic will work for me. Thanks dude.

      No problem, HamNRye, Perl doesn't discriminate against less capable systems. :)

      For what it's worth, File::MMagic's built-in magic file doesn't seem to include support for Macintosh binary, but all is not lost. Grab this file and pass its pathname to the File::MMagic constructor and it will most likely work (untested on Macintosh files, since I have none to test with at the moment).

        Well, File::MMagic does not have Magic Numbers for most of what we use, but I have been able to add EPS, QXD, AI, and INDD to the list of filetypes it knows about. I have tested them on both Mac and PC files, and all is well.

        All in all, an awesome module.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://256272]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-01-19 16:56 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (55 votes). Check out past polls.