Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: file command replacement (showing the type of a file with perl)

by halfcountplus (Hermit)
on Apr 17, 2012 at 12:41 UTC ( [id://965503]=note: print w/replies, xml ) Need Help??


in reply to file command replacement (showing the type of a file with perl)

the File::Type module, although not bad, is clearly less accurate that file.

You've misunderstood something. The explicit purpose of File::Type is "to determine the MIME type of that file".

'image/jpeg' is a valid MIME type. 'JPEG image data, JFIF standard 1.01' is not. MIME types are important, eg, in internet transfers -- your browser decides how to treat something based on the MIME type in the http header.

The file command (which will give you a mime type too, if you use the --mime switch) can provide more detailed information in a "human readable" form but there is no protocol for this. It looks to me like someone has written a module porting "file" into perl tho: file.

However, since the author admits "this implementation is significantly slower than the C version" you might be better off just using backticks ;).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-19 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found