Skip Menu |

This queue is for tickets about the File-MMagic CPAN distribution.

Report information
The Basics
Id: 11121
Status: new
Priority: 0/
Queue: File-MMagic

People
Owner: Nobody in particular
Requestors: perl-bug [...] owl.me.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.22
Fixed in: (no value)



Subject: Always returns application/octet-stream when $/ (RS) is undefined
perl v5.8.4, File::MMagic v1.22 I was having trouble with $mmagic->checktype_contents($image) returning 'application/octet-stream' in seemingly random situations. In the end, I discovered it was because I was doing the following: sub someSub { local $/ = undef; open F, $some_filename; my $image = <F>; close F; my $mimetype = $mmagic->checktype_contents($image); # ... etc } whereas the following code will set $mimetype correctly: sub someSub { my $image; { local $/ = undef; open F, $some_filename; $image = <F>; close F; } my $mimetype = $mmagic->checktype_contents($image); # ... etc } The problem stems back to the function readMagicEntry() in MMagic.pm, which contains two diamond (<FILEHANDLE>) operators, but doesn't localise $/ (input record separator) to its default value of "\n". I suspect (although I haven't tested it) adding the following line to the start of readMagicEntry() will fix the problem: local $/ = "\n"; I notice there is also a diamond in the checktype_filename() function, which will problem exhibit similar strangeness if used in a program with a non-default $/. I hope I've been helpful, and I'm sorry I don't have more time to test this thoroughly. ~ Rich Daley