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