I have a script that downloads files but these files do not have any information about them before they are downloaded. While writing for Linux I have just called qx{ 'file ' . $filename } to see if it is a JPEG image an if not delete it. However, I am now trying to rewrite to a platform independent and pure-Perl form. I have turned all the calls to system{ 'curl', $image_website } to LWP::UserAgent calls and I was hoping that there is some way to replace calls to file with something as well.
I have a script that downloads files but these files do not have any
Share
File::TypeCPAN module can help you – its description is “determine file type using magic” which is what Unixtypecommand does.Another option is
File::LibMagic(Perl wrapper for libmagic; file-4.x or file-5.x)