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

Hi all!

i need to use the Digest::Nilsimsa module for a project i'm doing, so i installed it ok, but when i tried running it i kept getting error messages about the script segfaulting... (ran it on perl 5.6.1 on a debian machine)

thing is, i need to know if the module works ok as i've a meeting with my supervisor later on today... is there some kind person out there who could try the code on their machine and tell me if they get a more successful result? would help to know if the problem is my machine rather than the code!

#!/usr/bin/perl -w use strict; use Digest::Nilsimsa; my $text = "this is a test string. hopefully it will produce a nilsims +a code."; my $nilsimsa = Digest::Nilsimsa; my $digest = $nilsimsa->text2digest($text); print "digest code is : " . $digest . "\n";

Replies are listed 'Best First'.
Re: CPAN module not working...
by planetscape (Chancellor) on Jul 26, 2006 at 13:02 UTC

    Hmmm... I note that the POD says:

    This module is a wrapper around nilsimsa implementation in C by cmeclax.

    Do you have that installed?

    HTH,

    planetscape
      well spotted! didn't install that, will do it now and try it again - thanks!
Re: CPAN module not working...
by Ovid (Cardinal) on Jul 26, 2006 at 13:19 UTC

    From what I can tell, this module has nilsimsa bundled with it. I'm at work and can't install it, though, so I would point out that the docs (and thus your code) have an error:

     my $nilsimsa = Digest::Nilsimsa;

    The package name there is a bareword; you need to call the constructor. From the tests:

    my $n = new Digest::Nilsimsa; print $n->testxs('iamchad') eq 'amchad' ? "" : "not ", "ok 2\n";

    (Though this is better written as Digest::Nilsimsa->new;.)

    Cheers,
    Ovid

    New address of my CGI Course.

Re: CPAN module not working...
by marto (Cardinal) on Jul 26, 2006 at 13:17 UTC
    Hi goff,

    I ran the following code:
    #!/usr/bin/perl use strict; use warnings; use Digest::Nilsimsa; my $text = "this is a test string. Hopefully it will produce a nilsims +a code."; my $nilsimsa = Digest::Nilsimsa->new(); my $digest = $nilsimsa->text2digest($text); print "digest code is : " . $digest . "\n";
    And recieved the following output:

    digest code is : febb4ebd89c689ae487d366dfc1f398ada1efdf9f4d68c3b65b6d4fd6844ecfe

    The differences between the code you posted and mine is the my $nilsimsa = Digest::Nilsimsa->new(); line. If, as per the documentation, I use my $nilsimsa = Digest::Nilsimsa; I get the following error:
    Bareword "Digest::Nilsimsa" now allowed while "strict subs" in use at +digest.pl line 8 Execution of digest.pl aborted due to compliation errors.

    I am using Strawberry Perl, v5.8.8 on Windows 2000 professional.

    Martin
      deadly, thanks! hadn't heard of Strawberry Perl before (haven't been programming at all in a few years), will check it out now...
Re: CPAN module not working...
by holli (Abbot) on Jul 26, 2006 at 13:08 UTC
    The module you are using is just a wrapper around nilsimsa implementation in C. Without looking at it firmly, I would blame the underlying C library, so you must make sure you have it properly installed/compiled.


    holli, /regexed monk/