http://www.perlmonks.org?node_id=1049077

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

Hi all

I installed Wiktionary::Parser on a Windows7 64bit operating system through ppm. The problem is that I get a error message rigth at the start of my script, even though (I think) the module installed correctly.

#!/usr/local/bin/perl -w use Wiktionary::Parser; my $parser = Wiktionary::Parser->new(); my $document = $parser->get_document(title => 'bunny'); print "$document";

The 'use Wiktionary::Parser;' gives the error message. Any ideas?

Thanks in advance for any help

Replies are listed 'Best First'.
Re: Compilation failed in require
by BrowserUk (Patriarch) on Aug 12, 2013 at 11:06 UTC

    The problem appears to be a relatively simple coding error in Wiktionary::Parser::Language.

    When it uses Locale::Codes::Language, is disables imports: use Locale::Codes::Language qw(); and attempts to obtain access to the constants, that would have been imported, by using fully qualified names:

    my @all_names_3 = Locale::Codes::Language::all_language_names(Locale:: +Codes::Language::LOCALE_LANG_ALPHA_3);

    The problem appears to be that those exports do not originate in that module, but rather are themselves imported from Locale::Codes::Constants.

    The real question here is how could Wiktionary::Parser work anywhere, regardless of how it was installed, given such a fundamental programming error?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      (Wiktionary::Parser author here)

      I've never tested this package on a Windows platform, but I'm pretty tickled that it worked as well as it did. I've mainly run the code on various versions of CentOS on perl 5.8 and 5.16 and never ran into any of the above issues.

      I pushed a few updates to try to fix some of them but since I can't recreate these errors I'm a bit blind as to whether it'll be effective.

      The latest version of Wikionary::Parser (v0.10) is available on github here right now: https://github.com/clbecker/perl-wiktionary-parser

      And should be on cpan as soon as it gets indexed. (If any of you have a better patch, let me know and I'll be happy to merge it in)

        I've never tested this package on a Windows platform, but I'm pretty tickled that it worked as well as it did. I've mainly run the code on various versions of CentOS on perl 5.8 and 5.16 and never ran into any of the above issues.

        It is hard to see how the particular coding error I identified as the cause of the OPs immediate problem would be in any way platform specific.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Compilation failed in require
by BrowserUk (Patriarch) on Aug 12, 2013 at 08:27 UTC
    I get a error message ... The 'use Wiktionary::Parser;' gives the error message.

    What is the "error message"?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      What is the "error message"?

      When I tried the OP's code here locally, I got:

      Bareword "Locale::Codes::Language::LOCALE_LANG_ALPHA_3" not allowed wh +ile "strict subs" in use at /home/soeren/perl5/lib/perl5/Wiktionary/P +arser/Language.pm line 49. Compilation failed in require at /home/soeren/perl5/lib/perl5/Wiktiona +ry/Parser/Section.pm line 8. BEGIN failed--compilation aborted at /home/soeren/perl5/lib/perl5/Wikt +ionary/Parser/Section.pm line 8. Compilation failed in require at /home/soeren/perl5/lib/perl5/Wiktiona +ry/Parser/Document.pm line 6. BEGIN failed--compilation aborted at /home/soeren/perl5/lib/perl5/Wikt +ionary/Parser/Document.pm line 6. Compilation failed in require at /home/soeren/perl5/lib/perl5/Wiktiona +ry/Parser.pm line 8. BEGIN failed--compilation aborted at /home/soeren/perl5/lib/perl5/Wikt +ionary/Parser.pm line 8. Compilation failed in require at test.pl line 2. BEGIN failed--compilation aborted at test.pl line 2.

      YMMV...

      Cheers, Sören

      Créateur des bugs mobiles - let loose once, run everywhere.
      (hooked on the Perl Programming language)

        When I tried the OP's code here locally, I got:

        I wonder if that the same error as the OP is seeing?

        YMMV...

        So might his...


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Compilation failed in require
by Khen1950fx (Canon) on Aug 12, 2013 at 10:22 UTC
    First, Wiktionary::Parser has few dependencies that need to updated before you install the parser. In a nutshell:
    #!/usr/bin/perl use strict; use warnings; use CPAN; my (@mods) = qw( File::Path Text::Unidecode JSON WWW::RobotRules HTTP::Cookies Net::FTP Net::HTTP IO::Socket HTTP::Daemon Digest::MD5 HTML::Tagset XSLoader HTML::Entities HTTP::Negotiate File::Listing Time::Local HTTP::Date Bundle::Compress::Zlib File::Temp Exporter Scalar::Util IO::HTML IO::Uncompress::Inflate HTTP::Status Encode Encode::Locale LWP::MediaTypes Test MIME::Base64 URI::EScape LWP::UserAgent MediaWiki::API Carp Spiffy ExtUtils::MakeMaker Filter::Util::Call Test::More Test::Base Test::CheckManifest Carp::Always Locale::Codes Wiktionary::Parser ); foreach my $mod (@mods) { CPAN::Shell->install($mod); }
    Second, don't forget to use a dumper. I used Data::Dumper::Concise. Using your script, I use derived_terms and synonyms:
    #!/usr/local/bin/perl -l use strict; use warnings; use Wiktionary::Parser; use Data::Dumper::Concise; my $parser = Wiktionary::Parser->new(); my $document = $parser->get_document( title => 'bunny' ); my $derived_words = $document->get_derived_terms(); my $synonyms = $document->get_synonyms(); print Dumper( $derived_words, $synonyms );

      OP used PPM, prerequsites are installed via PPM. Why have you scripted a cpan install when running cpan Wiktionary::Parser from the command line will do the same thing?

      Also note that OP said he was on Windows 7 64 bit, if they're using 64 bit ActiveState Perl no C compiler or build tools are installed by default, and aren't available on the 64bit platform from PPM. So without them manualling installing all this your suggestion of a cpan installation may fail.

      Update: Added link. Slight rewording for clarity

      First, Wiktionary::Parser has few dependencies that need to updated before you install the parser.

      First, when you "installed Wiktionary::Parser on a Windows7 64bit operating system through ppm", PPM should have resolved and installed all dependencies when it was built on the PPM server (by ActiveState or whomever runs the PPM server).


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      Hi

      After installing all of Wiktionary::Parser dependencies, I do not get the error message as before, so it seems to have worked.

      However when I try to run the script that you posted (I had a look at Wiktionary::Parser documentation and it looks correct), I get a new error message- 'Can't call method "get_derived_terms" on an undefined value at \some\dir\script.pl line 12'. Any ideas?

      Thank you for the help in my previous post, much appreciated

        The documentation is incorrect. You should have gotten this output:
        { en => [ "angst bunny", "badge bunny", "bunny girl", "bunny rabbit", "cuddle bunny", "dust bunny", "Easter Bunny", "gym bunny", "snuggle bunny", "that's the bunny", "bunny wunny", "snow bunny" ] } { en => { language => "English", sense => { "easy, unchallenging, of a slope" => [ "nursery" ], "resembling a bun" => [ "bunlike" ] } } }
        You'll have to improvise:)
Re: Compilation failed in require
by Anonymous Monk on Nov 30, 2013 at 13:57 UTC
    So the latest version of Wiktionary::Parser (0.11) should have fixed this error. In previous versions, the cpan testers reports for perl 5.14 on a number of platforms were showing the same issue, all of which are passing now. If the root cause was the same then this case should be resolved too.