Skip Menu |

This queue is for tickets about the Pod-Parser CPAN distribution.

Report information
The Basics
Id: 13203
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Pod-Parser

People
Owner: Marek.Rouchal [...] gmx.net
Requestors: radek42 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.32



Subject: Parser.pm support for output to object broken again
Hello, I have provided a patch to allow specifying objects (eg. IO::String) as output from the parser. It was integrated in 1.29, but broken in 1.30. If the variable can contain both a string and an object, then we have to test for ref() *before* testing for length(), "ne '-'" or =~ /.../, as the later tests would involve reading. Patch attached. -- Radoslaw Zielinski <radek at pld-linux.org>
diff -urN Pod-Parser-1.30/lib/Pod/Parser.pm PodParser-1.29/lib/Pod/Parser.pm --- Pod-Parser-1.30/lib/Pod/Parser.pm 2005-03-12 18:47:23.000000000 +0100 +++ PodParser-1.29/lib/Pod/Parser.pm 2005-02-08 23:52:36.000000000 +0100 @@ -1163,14 +1163,7 @@ local *_; ## Is $infile a filename or a (possibly implied) filehandle - $infile = '-' unless ((defined $infile) && (length $infile)); - if (($infile eq '-') || ($infile =~ /^<&(STDIN|0)$/i)) { - ## Not a filename, just a string implying STDIN - $infile ||= '-'; - $myData{_INFILE} = "<standard input>"; - $in_fh = \*STDIN; - } - elsif (ref $infile) { + if (ref $infile) { if (ref($infile) =~ /^(SCALAR|ARRAY|HASH|CODE|REF)$/) { croak "Input from $1 reference not supported!\n"; } @@ -1179,6 +1172,14 @@ $myData{_INFILE} = ${$infile}; $in_fh = $infile; } + elsif (!defined($infile) || !length($infile) || ($infile eq '-') + || ($infile =~ /^<&(?:STDIN|0)$/i)) + { + ## Not a filename, just a string implying STDIN + $infile ||= '-'; + $myData{_INFILE} = "<standard input>"; + $in_fh = \*STDIN; + } else { ## We have a filename, open it for reading $myData{_INFILE} = $infile; @@ -1194,20 +1195,7 @@ ## already ## Is $outfile a filename, a (possibly implied) filehandle, maybe a ref? - if (!defined($outfile) || !length($outfile) || ($outfile eq '-') - || ($outfile =~ /^>&?(?:STDOUT|1)$/i)) - { - if (defined $myData{_TOP_STREAM}) { - $out_fh = $myData{_OUTPUT}; - } - else { - ## Not a filename, just a string implying STDOUT - $outfile ||= '-'; - $myData{_OUTFILE} = "<standard output>"; - $out_fh = \*STDOUT; - } - } - elsif (ref $outfile) { + if (ref $outfile) { ## we need to check for ref() first, as other checks involve reading if (ref($outfile) =~ /^(ARRAY|HASH|CODE)$/) { croak "Output to $1 reference not supported!\n"; @@ -1227,6 +1215,19 @@ $out_fh = $outfile; } } + elsif (!defined($outfile) || !length($outfile) || ($outfile eq '-') + || ($outfile =~ /^>&?(?:STDOUT|1)$/i)) + { + if (defined $myData{_TOP_STREAM}) { + $out_fh = $myData{_OUTPUT}; + } + else { + ## Not a filename, just a string implying STDOUT + $outfile ||= '-'; + $myData{_OUTFILE} = "<standard output>"; + $out_fh = \*STDOUT; + } + } elsif ($outfile =~ /^>&(STDERR|2)$/i) { ## Not a filename, just a string implying STDERR $myData{_OUTFILE} = "<standard error>";
Thanks for the patch, applied with slight modification. I apologize for the inconvenience. -Marek