HTML::Form->Parse (Perl) not working under Fedora Core 1

  • Thread starter Jeffrey J. Kosowsky
  • Start date
J

Jeffrey J. Kosowsky

I have been having trouble getting the HTML::Form library to work
under Fedora Core 1 (perl 5.8.1-92 with perl-libwww-perl-5.65-6). For
some reason, the function HTML::Form->Parse doesn't return any forms
for me.

For example, the following simple perl script:
#! /usr/bin/perl

use HTML::Form;
use HTTP::Request;
use LWP;

my $ua = new LWP::UserAgent;
my $uri="http://www.google.com";
my $req = HTTP::Request->new(GET => $uri);
my $res = $ua->request($req);
print $res->content;
my $form = HTML::Form->parse($res->content, $res->base());
print "Form: ${form}\n";

Returns the source of the www.google.com page but fails to return the
obvious embedded form.

The only potential problem I see is that the library Form.pm is stored
under: /usr/lib/perl5/vendor_perl/5.8.0/HTML/Form.pm (rather than 5.8.1)

I did not have any problems with this previously under RH8.0 with perl
5.8.0-88 and perl-libwww-perl-5.65-2.noarch.rpm)

Has anything changed in perl? Am I doing something wrong here? Any
suggestions on what might be going on?

Thanks,
Jeff
 
G

Gunnar Hjalmarsson

Jeffrey said:
I have been having trouble getting the HTML::Form library to work

my $form = HTML::Form->parse($res->content, $res->base());
print "Form: ${form}\n";

... fails to return the obvious embedded form.

You are printing the object reference! Please study the documentation
for the module you are trying to use.
 
J

Jeffrey J. Kosowsky

Gunnar Hjalmarsson said:
You are printing the object reference! Please study the documentation
for the module you are trying to use.

I know that -- but the fact is that it returns an empty reference --
i.e. no form! (which is all I was trying to show with this short dummy script)

If you want to do it your way by printing say:
join(" ", $form->form);

I get the corresponding error message:
"Can't call method "form" on an undefined value at ./myscript.pl line 14"
which occurs presumably because no form is returned!

My approach was used just to simplify the script and get at the "root"
of the problem.

So... my question still stands...
 
G

Gunnar Hjalmarsson

Jeffrey said:
I know that -- but the fact is that it returns an empty reference
-- i.e. no form! (which is all I was trying to show with this short
dummy script)

It worked fine when I tried it, which probably is the reason why I
misunderstood the nature of the problem. Sorry!
So... my question still stands...

Okay, let me try again:

First I'd add the -w switch to the shebang line (to enable warnings
dynamically) and enable strictures. Then instead of

my $form = HTML::Form->parse($res->content, $res->base());

I'd do:

my $form;
eval { $form = HTML::Form->parse($res->content, $res->base()) };
die $@ if $@;

to try to capture the explanation in the error log.
 
J

Jeffrey J. Kosowsky

I have been having trouble getting the HTML::Form library to work
under Fedora Core 1 (perl 5.8.1-92 with perl-libwww-perl-5.65-6). For
some reason, the function HTML::Form->Parse doesn't return any forms
for me.

For example, the following simple perl script:
#! /usr/bin/perl

use HTML::Form;
use HTTP::Request;
use LWP;

my $ua = new LWP::UserAgent;
my $uri="http://www.google.com";
my $req = HTTP::Request->new(GET => $uri);
my $res = $ua->request($req);
print $res->content;
my $form = HTML::Form->parse($res->content, $res->base());
print "Form: ${form}\n";

Returns the source of the www.google.com page but fails to return the
obvious embedded form.

Definitely seems to be a problem with Fedora Core1 version of Perl
(and/or anything I may have done subsequently to screw up my Perl
installation :), because when I 'chroot'ed over to my old RH8.0
installation, everything worked again as expected.

On the other hand, I really have a pretty stock Fedora installation
and I have not done anything to perl except to install one package
(perl-Video-DVDRip_0.50.16-2.fr_i386.rpm). Also, my other basic perl
scripts seem to still work.

Any suggestions?
 
J

Jeffrey J. Kosowsky

Okay, let me try again:

First I'd add the -w switch to the shebang line (to enable warnings
dynamically) and enable strictures. Then instead of

my $form = HTML::Form->parse($res->content, $res->base());

I'd do:

my $form;
eval { $form = HTML::Form->parse($res->content, $res->base()) };
die $@ if $@;

to try to capture the explanation in the error log.

Thanks for the suggestion.
Tried it, but still get the following error message:
Can't call method "form" on an undefined value at ./myscript.pl line 17.

You mention an error log, but not sure which log you are referring to.

I have a pretty stock Fedora Core 1 implementation with only one added
perl package (perl-Video-DVDRip_0.50.16-2.fr_i386.rpm) beyond the
standard perl packages that come with Fedora. Also, when I 'chroot'ed
over to my old RedHat8.0 installation, it all worked fine.

My other perl scripts seem to work fine, so I am assuming perl is
basically intact.

Any help on how to debug/fix further?
 
G

Gunnar Hjalmarsson

Jeffrey said:
Thanks for the suggestion.
Tried it, but still get the following error message:
Can't call method "form" on an undefined value at ./myscript.pl
line 17.

So then we know that the module does not generate a fatal error. (I
assume that line 17 is after the die statement.)
You mention an error log, but not sure which log you are referring
to.

Well, maybe I'm 'thinking CGI'... If you run the program from the
command line, you should see any error or warning messages.
Any help on how to debug/fix further?

I'm out of ideas now. Sorry.
 
J

Jeffrey J. Kosowsky

I have been having trouble getting the HTML::Form library to work
under Fedora Core 1 (perl 5.8.1-92 with perl-libwww-perl-5.65-6). For
some reason, the function HTML::Form->Parse doesn't return any forms
for me.

For example, the following simple perl script:
#! /usr/bin/perl

use HTML::Form;
use HTTP::Request;
use LWP;

my $ua = new LWP::UserAgent;
my $uri="http://www.google.com";
my $req = HTTP::Request->new(GET => $uri);
my $res = $ua->request($req);
print $res->content;
my $form = HTML::Form->parse($res->content, $res->base());
print "Form: ${form}\n";

Returns the source of the www.google.com page but fails to return the
obvious embedded form.

The only potential problem I see is that the library Form.pm is stored
under: /usr/lib/perl5/vendor_perl/5.8.0/HTML/Form.pm (rather than 5.8.1)

I did not have any problems with this previously under RH8.0 with perl
5.8.0-88 and perl-libwww-perl-5.65-2.noarch.rpm)

The cause of the problem is as follows:

The function report_tags in the Perl module HTML::parser does not give
the right result when using the current
perl-HTML-Parser-3.26-18.i386.rpm package which apparantly was
compiled against an earlier version of Perl. (Among other things, this
causes the Perl function, HTML::Form->Parse to fail as noted in my
original posting).

It appears that the problem is due to a binary incompatibility between
Perl 5.8.0 and 5.8.1 caused by the introduction of hash randomization
in Perl 5.8.1. (Note that the report_tags function is defined as an
HV*).

The solution is to simply rebuild the src rpm under Fedora Core 1/Perl
5.8.1.

I am not sure if this binary incompatibility between Perl 5.8.0 and
5.8.1 affects any other Perl modules, but it might be a good idea to
check this out and see whether any of the other Perl packages need to
be rebuilt for Fedora Core 1.

I am surprised though that no one else has noticed this bug yet, since
it seems to affect a pretty fundamental Perl module...
 
J

James Willmore

On Wed, 24 Dec 2003 06:25:14 GMT
(e-mail address removed) (Jeffrey J. Kosowsky) writes:
The cause of the problem is as follows:

The function report_tags in the Perl module HTML::parser does not
give the right result when using the current
perl-HTML-Parser-3.26-18.i386.rpm package which apparantly was
compiled against an earlier version of Perl. (Among other things,
this causes the Perl function, HTML::Form->Parse to fail as noted in
my original posting).

It appears that the problem is due to a binary incompatibility
between Perl 5.8.0 and 5.8.1 caused by the introduction of hash
randomization in Perl 5.8.1. (Note that the report_tags function is
defined as an HV*).

The solution is to simply rebuild the src rpm under Fedora Core
1/Perl 5.8.1.

I am not sure if this binary incompatibility between Perl 5.8.0 and
5.8.1 affects any other Perl modules, but it might be a good idea to
check this out and see whether any of the other Perl packages need
to be rebuilt for Fedora Core 1.

I am surprised though that no one else has noticed this bug yet,
since it seems to affect a pretty fundamental Perl module...

No offense, but I don't bother with RPM's when it comes to Perl
modules. In fact, given your position (a new install of Fedora), the
*first* thing I'd do is use the CPAN shell and start updating *all*
the modules. Because the *most* of the Perl modules that come with
*most* distros are horribly out of date "out of the box". And the
RPM's are usually not much better.

I'd get used to using the CPAN shell instead of using the RPM's - but
that's just my opinion :)

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
To iterate is human, to recurse, divine.
 
J

Jeffrey J. Kosowsky

James Willmore said:
No offense, but I don't bother with RPM's when it comes to Perl
modules. In fact, given your position (a new install of Fedora), the
*first* thing I'd do is use the CPAN shell and start updating *all*
the modules. Because the *most* of the Perl modules that come with
*most* distros are horribly out of date "out of the box". And the
RPM's are usually not much better.

I'd get used to using the CPAN shell instead of using the RPM's - but
that's just my opinion :)

No offense taken... but as a perennial perl newbie, I don't know much
about the CPAN shell.

I tend to use RPMS as time-savers so I don't have to worry about
updating and rebuilding apps.

What is the CPAN shell? Is it like a perl version of up2date/yum/apt?

Jeff
 
J

James Willmore

No offense, but I don't bother with RPM's when it comes to Perl
modules. In fact, given your position (a new install of Fedora),
the*first* thing I'd do is use the CPAN shell and start updating
*all* the modules. Because the *most* of the Perl modules that
come with*most* distros are horribly out of date "out of the box".
And the
RPM's are usually not much better.

I'd get used to using the CPAN shell instead of using the RPM's -
but that's just my opinion :)

No offense taken... but as a perennial perl newbie, I don't know
much about the CPAN shell.

I tend to use RPMS as time-savers so I don't have to worry about
updating and rebuilding apps.

What is the CPAN shell? Is it like a perl version of
up2date/yum/apt?[/QUOTE]

perldoc CPAN -or- man CPAN

It aids in updating Perl modules - in much the same way as the
utilities you mentioned.

I would ditch the RPM idea - like I stated before. I foresee many
issues in the future using RPM's, but that been my experience.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Is your job running? You'd better go catch it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top