I will try to explain this as clearly as I can. I would appreciate your help very much.

I am using File::MMagic module to determine if a particular file is an mpeg file. I have tried this on 2 separate hosted linux systems.

Here is what I do

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";

I upload mp3 file via HTML form and then check its mime type. For the same file, it worked on one system, but failed on the other.

I get the following error

Invalid type 'regex' at line 271 Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/s +ite_perl/5.8.8/File/MMagic.pm line 767, <GEN0> line 276.

I checked the Perl module version using

perl -MFile::MMagic -le 'print $File::MMagic::VERSION'

It showed 1.27 on both systems

if I do a uname -a, it gives me

For the system where it fails,

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

For the system where it works,

Linux xxx.com 2.6.18-028stab095.1-ent #1 SMP Mon Oct 24 20:45:18 MSD 2 +011 i686 i686 i386 GNU/Linux

I even ftp'd the mpeg file on which it is failing, to the system where it works. It did not have problems and determined the mime type fine.

What confuses me it that existing mp3 files work fine on both systems. But if I upload a file using http, it seems to be failing on one of the systems. It appears like files uploaded via http on one of the systems

Any suggestions as to why this may be happening. Thanks


In reply to Problem with uploaded (http) files with File::MMagic by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.