As everybody surely knows, the "file" command in bash prints info about the type of a file. (i.e file flower.jpg will show that this is a jpeg image)
I'm trying to achieve the same in a perl script. Thus I wrote something like this:
use strict; use File::Type; my $infile = "flower.jpg"; my $ft = File::Type->new(); my $type1 = $ft->checktype_filename($infile); my $type2 = $ft->mime_type($infile); print "$type1\n"; print "$type2\n"; print `file $infile`;
and my proto-script returns
image/jpeg image/jpeg flower.jpg: JPEG image data, JFIF standard 1.01
Thus we have a clear winner, the File::Type module, although not bad, is clearly less accurate that file. And that's the question: żDo you know any way/module/function integrated with perl to obtain the same amount of info about a file? or I need to use system here to call directly the file command?. The big nuisance here is that if you search for file + perl in google you obtain millions of unrelated results
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |