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

Discussion in 'Perl Misc' started by Jeffrey J. Kosowsky, Dec 17, 2003.

  1. 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
     
    Jeffrey J. Kosowsky, Dec 17, 2003
    #1
    1. Advertising

  2. Jeffrey J. Kosowsky wrote:
    > I have been having trouble getting the HTML::Form library to work


    <snip>

    > 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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Dec 17, 2003
    #2
    1. Advertising

  3. Gunnar Hjalmarsson <> writes:
    > Jeffrey J. Kosowsky wrote:
    > > I have been having trouble getting the HTML::Form library to work

    >
    > <snip>
    >
    > > 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.
    >
    > --
    > Gunnar Hjalmarsson
    > Email: http://www.gunnar.cc/cgi-bin/contact.pl


    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...
     
    Jeffrey J. Kosowsky, Dec 17, 2003
    #3
  4. Jeffrey J. Kosowsky wrote:
    > Gunnar Hjalmarsson writes:
    >> Jeffrey J. Kosowsky wrote:
    >>> I have been having trouble getting the HTML::Form library to
    >>> work

    >>
    >> You are printing the object reference!

    >
    > 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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Dec 17, 2003
    #4
  5. der (Jeffrey J. Kosowsky) writes:
    > 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?
     
    Jeffrey J. Kosowsky, Dec 17, 2003
    #5
  6. Gunnar Hjalmarsson <> writes:
    > Jeffrey J. Kosowsky wrote:
    > > Gunnar Hjalmarsson writes:
    > >> Jeffrey J. Kosowsky wrote:
    > >>> I have been having trouble getting the HTML::Form library to
    > >>> work


    > 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?
     
    Jeffrey J. Kosowsky, Dec 17, 2003
    #6
  7. Jeffrey J. Kosowsky wrote:
    > Gunnar Hjalmarsson writes:
    >> 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.


    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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Dec 17, 2003
    #7
  8. SOLVED:: HTML::Form->Parse (Perl) not working under Fedora Core 1

    der (Jeffrey J. Kosowsky) writes:

    > 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...
     
    Jeffrey J. Kosowsky, Dec 24, 2003
    #8
  9. Re: SOLVED:: HTML::Form->Parse (Perl) not working under Fedora Core1

    On Wed, 24 Dec 2003 06:25:14 GMT
    der (Jeffrey J. Kosowsky) wrote:
    > der (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.
     
    James Willmore, Dec 24, 2003
    #9
  10. Re: SOLVED:: HTML::Form->Parse (Perl) not working under Fedora Core 1

    James Willmore <> writes:
    > 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
     
    Jeffrey J. Kosowsky, Dec 24, 2003
    #10
  11. Re: SOLVED:: HTML::Form->Parse (Perl) not working under Fedora Core1

    On Wed, 24 Dec 2003 16:36:11 GMT
    der (Jeffrey J. Kosowsky) wrote:

    > James Willmore <> writes:
    > > 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?


    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!
     
    James Willmore, Dec 25, 2003
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Trent

    JAR help in FEDORA CORE 2

    Trent, May 27, 2004, in forum: Java
    Replies:
    1
    Views:
    429
    David Lesaffre
    May 28, 2004
  2. AnonymousFC4
    Replies:
    7
    Views:
    2,396
    Jon Martin Solaas
    Aug 9, 2005
  3. jabelsc
    Replies:
    0
    Views:
    616
    jabelsc
    Mar 6, 2006
  4. J Dubal
    Replies:
    2
    Views:
    337
    J Dubal
    Oct 2, 2004
  5. luc2
    Replies:
    2
    Views:
    188
    Simon Andrews
    Jun 29, 2007
Loading...

Share This Page