use File::MMagic; my $path='/path/to/file.doc'; my $mm= new File::MMagic; #use internal magic file my $t = $mm->checktype_filename("$path"); # $t holds mime type- doesn't matter what the file extension or no extension is