perller has asked for the wisdom of the Perl Monks concerning the following question:

packaging WWW::Mechanize with javascript support is resulting in an exe file that produces this error:
Can't find string terminator "r" anywhere before EOF at HTML/DOM/Inter +face.pm li ne 83. Compilation failed in require at WWW/Mechanize/Plugin/DOM/Window.pm li +ne 8. BEGIN failed--compilation aborted at WWW/Mechanize/Plugin/DOM/Window.p +m line 8. Compilation failed in require at WWW/Mechanize/Plugin/DOM.pm line 21. BEGIN failed--compilation aborted at WWW/Mechanize/Plugin/DOM.pm line +21. Compilation failed in require at script/kslsend.pl line 6. BEGIN failed--compilation aborted at script/kslsend.pl line 6.
I am using PAR-Packer-0.982 and just packaging this test file:
#!/usr/bin/perl use warnings; use strict; use WWW::Mechanize; use WWW::Mechanize::Plugin::JavaScript; use WWW::Mechanize::Plugin::DOM; use HTTP::Cookies; my $agent = WWW::Mechanize->new(); $agent->use_plugin('JavaScript'); exit;
perl2exe didn't work it produced all kind of errors, I'm new to perl,and i was hoping you guys would help me out...thank you

Replies are listed 'Best First'.
Re: PP packaging Mechanize problem
by Corion (Patriarch) on Oct 12, 2008 at 07:30 UTC

    Actually, your problem is not with WWW::Mechanize, but with HTML::DOM respectively HTML::DOM::Interface.

    Looking at line 83, I see the following code:

    ... # (which was just hack after hack), but is now maintained manually +. 0 and q r =for ; our @EXPORT_OK = qw/METHOD VOID READONLY BOOL STR NUM OBJ TYPE/; ...

    Which seems to be a weird "comment block" commenting between the q r and the =for line. I don't know why this triggers a Perl error, but it might be that your (unstated) version of Perl copes differently with the POD directives, or some preprocessing part of PAR strips the POD and thus wrongly messes up the code.

    If you strip out these three lines, you should get a different error or it should work.

      I don't know why this triggers a Perl error,

      Sounds like it's meant to be treated as a q'...' construct with "r" as the delimiter. Sounds like it is treated as such, but doesn't see the "r" in "=for ;" like it is meant to.

      I just tested with Perl 5.8.8 and Perl 5.10.0 and it works for me. Maybe the packager is stripping the pods to reduce the size of the package???

        This diagnosis is spot on. The documentation says:

        By default, PAR strips POD sections from bundled modules. In case that causes trouble, you can turn this off by setting the environment variable PAR_VERBATIM to 1.

        ... so I guess doing that would also help in this case.

Re: PP packaging Mechanize problem
by perller (Initiate) on Oct 13, 2008 at 01:23 UTC
    Thanks for the help...I commented the 2 lines and now i can package it. But the packaged script is not working. it stops at :
    $agent->use_plugin('JavaScript');
    So running the EXE file of the following script outputs Test1, and it just stops with no errors.
    #!/usr/bin/perl use strict; use WWW::Mechanize; use WWW::Mechanize::Plugin::JavaScript; use WWW::Mechanize::Plugin::DOM; use HTTP::Cookies; use IO::Handle; open OUTPUT, '>', "output.txt" or die $!; open ERROR, '>', "error.txt" or die $!; STDOUT->fdopen( \*OUTPUT, 'w' ) or die $!; STDERR->fdopen( \*ERROR, 'w' ) or die $!; my $agent = WWW::Mechanize->new(); print "Test1\n"; $agent->use_plugin('JavaScript'); print "Test2\n"; exit;
    The perl script works fine, but the exe file doesn't so i'm guessing the problem is with packaging dependencies for the javascript support ?

    Then again it does not give any error, any ideas on what could be causing this ? (I am using perl 5.8.8)