Skip Menu |

This queue is for tickets about the podlators CPAN distribution.

Report information
The Basics
Id: 40642
Status: resolved
Priority: 0/
Queue: podlators

People
Owner: RRA [...] cpan.org
Requestors: schwern [...] pobox.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.2.0
Fixed in: 2.2.1



CC: perl5-porters [...] perl.org, bug-podlators [...] rt.cpan.org
Subject: Re: [PATCH] v5.10.0 Pod/Text.pm Can't call method "pod2text" without a package or object
Date: Mon, 03 Nov 2008 17:42:58 -0800
To: Jari Aalto <jari.aalto [...] cante.net>
From: Michael G Schwern <schwern [...] pobox.com>
Jari Aalto wrote: Show quoted text
> ERROR CONDITION (5.10.0) > > Can't call method "pod2text" without a package or object reference > at /home/jaalto/tmp/t.pl line 12. > > TEST SCRIPT > > #!/usr/bin/perl > > use strict; > use English; > > =pod > > Test POD > > =cut > > pod2text $PROGRAM_NAME; > > PATCH TO FIX THIS
I don't think that's broken. Pod::Text was never loaded so there is no pod2text() function to call. If there is a problem it's the misleading error message thinking that it's indirect object syntax and not a function call, but that's a deep problem with indirect object syntax. But there is a problem, it's what happens when you do load Pod::Text. English is irrelevant so I'm using $0 instead. #!/usr/bin/perl use strict; use Pod::Text. =pod Test POD =cut pod2text $0; __END__ 5.8.8 (Pod::Text 3.08) says this: Can't use string ("") as a symbol ref while "strict refs" in use at /usr/local/perl/5.8.8/lib/Pod/Text.pm line 249. 5.10.0 (Pod::Text 3.12) says this: Can't use string ("") as a symbol ref while "strict refs" in use at /usr/local/perl/5.10.0/lib/5.10.0/Pod/Text.pm line 262. 5.6.2 (Pod::Text 2.08) works: Test POD which is what your patch is trying to fix? But, IMHO, I don't think the solution is to paper over the lack of $self->{output_fh} but to figure out why it didn't get initialized in the first place. It seems Pod::Text is using Pod::Simple incorrectly. It should be setting output_fh() itself and use it as a method accessor. From the Pod::Simple docs... "$parser->output_fh( *OUT );" This sets the filehandle that $parser's output will be written to. You can pass *STDOUT, otherwise you should probably do something like this: my $outfile = "output.txt"; open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!"; $parser->output_fh(*TXTOUT); ...before you call one of the "$parser->parse_whatever" methods. Pod::Simple does have a parse_from_file() method which is "An emulation of Pod::Parser's interface, for the sake of Perldoc" and does do the output_fh() setting. If Pod::Text uses that then things work fine. Then again, pod2text() as a function has been deprecated for about 8 years. -- Just call me 'Moron Sugar'. http://www.somethingpositive.net/sp05182002.shtml
CC: perl5-porters [...] perl.org, bug-podlators [...] rt.cpan.org
Subject: Re: [PATCH] v5.10.0 Pod/Text.pm Can't call method "pod2text" without a package or object
Date: Mon, 03 Nov 2008 19:32:25 -0800
To: Jari Aalto <jari.aalto [...] cante.net>
From: Michael G Schwern <schwern [...] pobox.com>
Michael G Schwern wrote: Show quoted text
> Pod::Simple does have a parse_from_file() method which is "An emulation of > Pod::Parser's interface, for the sake of Perldoc" and does do the output_fh() > setting. If Pod::Text uses that then things work fine.
Attached is the test and patch to Pod::Text. -- Hating the web since 1994.
diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm index f363303..eb9759d 100644 --- a/lib/Pod/Text.pm +++ b/lib/Pod/Text.pm @@ -609,7 +609,7 @@ sub pod2text { close $fh; return $retval; } else { - return $parser->parse_file (@_); + return $parser->parse_from_file (@_); } } diff --git a/t/pod2text_selftest.pod b/t/pod2text_selftest.pod new file mode 100644 index 0000000..b7ad9d0 --- /dev/null +++ b/t/pod2text_selftest.pod @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +use strict; +use Pod::Text; + +=pod + +Test POD + +=cut + +pod2text $0; diff --git a/t/pod2text_selftest.t b/t/pod2text_selftest.t new file mode 100644 index 0000000..f8337bb --- /dev/null +++ b/t/pod2text_selftest.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w + +use strict; +use Test::More tests => 2; + +my $doc = `$^X "-Ilib" t/pod2text_selftest.pod`; +is $?, 0; +is $doc, <<END; + Test POD + +END
Subject: Re: [rt.cpan.org #40642] Re: [PATCH] v5.10.0 Pod/Text.pm Can't call method "pod2text" without a package or object
Date: Mon, 03 Nov 2008 20:13:36 -0800
To: bug-podlators [...] rt.cpan.org
From: Russ Allbery <rra [...] stanford.edu>
"Michael G Schwern via RT" <bug-podlators@rt.cpan.org> writes: Show quoted text
> It seems Pod::Text is using Pod::Simple incorrectly. It should be > setting output_fh() itself and use it as a method accessor. From the > Pod::Simple docs... > > "$parser->output_fh( *OUT );" > This sets the filehandle that $parser's output will be written to. > You can pass *STDOUT, otherwise you should probably do something > like this: > > my $outfile = "output.txt"; > open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!"; > $parser->output_fh(*TXTOUT); > > ...before you call one of the "$parser->parse_whatever" methods.
Good catch, thank you. This will be fixed in the next release. -- Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
I just released podlators 2.2.1, which includes the fix for this problem. Thank you!