The problem is a result of the use of bare word file handles in code. The problem here is
primarily the use of FILE inside sub parsefile.
More info can be found at these links:
http://search.cpan.org/~jesse/perl-5.14.0/pod/perldelta.pod#Dereferencing_typeglobs
http://rt.perl.org/rt3/Public/Bug/Display.html?id=77810
This patch resolves things.
diff --git a/Parser.pm b/Parser.pm
index edf7856..dc827cb 100644
--- a/Parser.pm
+++ b/Parser.pm
@@ -215,9 +215,9 @@ sub parsestring {
sub parsefile {
my $self = shift;
my $file = shift;
- local(*FILE);
- open(FILE, $file) or croak "Couldn't open $file:\n$!";
- binmode(FILE);
+
+ open(my $fh, $file) or croak "Couldn't open $file:\n$!";
+ binmode($fh);
my @ret;
my $ret;
@@ -225,16 +225,16 @@ sub parsefile {
if (wantarray) {
eval {
- @ret = $self->parse(*FILE, @_);
+ @ret = $self->parse($fh, @_);
};
}
else {
eval {
- $ret = $self->parse(*FILE, @_);
+ $ret = $self->parse($fh, @_);
};
}
my $err = $@;
- close(FILE);
+ close($fh);
die $err if $err;
return unless defined wantarray;
diff --git a/t/stream.t b/t/stream.t
index 92b7994..6a5c140 100644
--- a/t/stream.t
+++ b/t/stream.t
@@ -32,19 +32,19 @@ close(OUT);
my $parser = new XML::Parser(Stream_Delimiter => $delim,
Handlers => {Comment => sub {$cnt++;}});
-open(FOO, $tmpfile);
+open($FOO, $tmpfile);
-$parser->parse(*FOO);
+$parser->parse($FOO);
print "not " if ($cnt != 37);
print "ok 2\n";
$cnt = 0;
-$parser->parse(*FOO);
+$parser->parse($FOO);
print "not " if ($cnt != 37);
print "ok 3\n";
-close(FOO);
+close($FOO);
unlink($tmpfile);