1

In a nutshell, I'm trying to use some modules, and they don't work, no warnings, errors, runtime errors, crashes, nothing, just no results. Specifically, I have

use strict;
use warnings;
use Lingua::Identify qw(:language_identification);

...

foreach my $f ( @txt ){
    my $s = &fileasstring( $f );
    my @l = langof( $s );           #  problem's here!
    &error( "!\nl=".scalar(@l)."\n" );
    foreach( @l ){ &error( "!$f\t[$_]\n" ); }
    &error( "\n" );
    }

and the output from running 'perl langs.pl' is

[da.txt]  reading file
[da.txt]    8 lines read
[da.txt]  done

da.txt  [Artikel 26. Enhver har ret til undervisning.  ...  som vedkommende har skabt.  ]

l=42
da.txt  [da]
da.txt  [0.278009331769791]
da.txt  [sv]
da.txt  [0.126520770367313]
da.txt  [nl]
da.txt  [0.0886509276813543]
...

and when running 'langs.exe' which seemingly perlapped just fine, I get

[da.txt]  reading file
[da.txt]    8 lines read
[da.txt]  done

da.txt  [Artikel 26. Enhver har ret til undervisning.  ...  som vedkommende har skabt.  ]

l=0

and that's it, no returned values from langof(), just an empty array.

The debugging info above shows that the file was read correctly (one each for da, de, en, es, fr, and several other languages), so it at least goes through the motions, but apparently perlapp finds modules well enough not to throw errors or warnings when compiling or at runtime, yet when compiled it, that routine within Identify just returns nothing.

  • I'm not too familiar with PerlApp because I don't use ActiveState Perl, but have you tried a similar tool, e.g., [PAR::Packer](https://metacpan.org/pod/PAR::Packer)? – Matt Jacob Jan 06 '16 at 20:31
  • It needs to be a standalone program to run on servers which wouldn't have any version of perl installed, but I'll look into it, tnx! – user5754171 Jan 07 '16 at 21:20
  • Right, which is one of the things PAR::Packer does (specifically, the `pp` tool). – Matt Jacob Jan 07 '16 at 21:48
  • Actually, I believe I found it. It uses Class::Factory::Util to scan the underlying dir for language modules (eg, 'EN.pm'), and 'require's each one in turn, so I just got the list and while 'require'ing each module didn't work, 'use'ing each one did. A hack, I know, but it works even when compiled. – user5754171 Jan 08 '16 at 22:36

1 Answers1

0

I am not 100% certain of what is wrong here but I would check the following things:

  • Check that $s does in fact contain some text (just add a print statement)
  • PerlApp handling of utf-8 and module loading, perl packers usually require much more thorough reading of the documentation than they let on.
  • Check what languages Lingua::Identify actually has loaded before running the identify loop, never assume anything!

As a last resort, try using PAR::Packer to "compile" your program.

Also, why are you calling fileasstring() with the & convention?

Tanami
  • 196
  • 2
  • 3
  • 11
  • 1. Absolutely. That's the middle part of the debugging info, the "Artikel 26" text, making sure I do in fact have the text as given. – user5754171 Jan 07 '16 at 21:10
  • Whups, sorry, no idea what happened. – user5754171 Jan 07 '16 at 21:10
  • ...

    2. That's what I'm afraid of, and was wondering if anyone had pointers/tips/tricks to that end.

    3. I *believe* it does so internally, but I was going to have to check that at some point, too. I'm running 5.20, and I've had people running 5.16 and 5.12, I believe, to also try it, all no-joy.

    These all have to be run on servers without any version of perl, as standalone units.

    That was the convention I learned perl with. :)
    – user5754171 Jan 07 '16 at 21:17