use File::MMagic; my $magicFile = '/usr/share/file/magic.mime'; my $mm = new File::MMagic->new($magicFile); my $filePath = $ARGV[0]; my $fh = new FileHandle "< $filePath"; my $res = $mm->checktype_filehandle($fh); print "$res\n"; #### Invalid type 'regex' at line 271 Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/site_perl/5.8.8/File/MMagic.pm line 767, line 276. #### perl -MFile::MMagic -le 'print $File::MMagic::VERSION' #### uname -a Linux xxx.com 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux #### Linux xxx.com 2.6.18-028stab095.1-ent #1 SMP Mon Oct 24 20:45:18 MSD 2011 i686 i686 i386 GNU/Linux