Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

How can I fix the problem in using the Algorithm::Permute module?

by supriyoch_2008 (Monk)
on Feb 27, 2013 at 07:09 UTC ( [id://1020812]=perlquestion: print w/replies, xml ) Need Help??

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

Hi PerMonks,

I have come across a perl module i.e. Algorithm::Permute which can find out the permutations of r elements of n where r<n. I have installed the Algorithm from cpan writing the text on cmd as "cpan Algorithm::Permute" and then pressing "enter". I got the following results:

Results about Algorithm::Permute Installation: Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\DR SUPRIYO>cpan Algorithm::Permute Set up gcc environment - 3.4.5 (mingw-vista special r3) Going to read 'C:\Perl\cpan\Metadata' Database was generated on Tue, 26 Feb 2013 12:07:54 GMT Algorithm::Permute is up to date (0.12).

Then I tried to run the script try5.pl (given below) in cmd several times but it gave the wrong results like:

Here goes the script try5.pl

#!/usr/bin/perl use warnings; use strict; use Algorithm::Permute; my @a=qw/ A B C /; # You can create r of n objects permutation generator, where r <= n my $p=new Algorithm::Permute(@a,2); while (@res = $p->next) { print join(", ", @res), "\n"; } exit; # Script ends here
RESULTS of try5.pl in cmd: C:\Users\DR SUPRIYO>cd desktop C:\Users\DR SUPRIYO\Desktop>try5.pl Can't locate loadable object for module Algorithm::Permute in @INC (@I +NC contain s: C:/Perl/site/lib C:/Perl/lib .) at C:\Users\DR SUPRIYO\Desktop\try5 +.pl line 4 Compilation failed in require at C:\Users\DR SUPRIYO\Desktop\try5.pl l +ine 4. BEGIN failed--compilation aborted at C:\Users\DR SUPRIYO\Desktop\try5. +pl line 4. C:\Users\DR SUPRIYO\Desktop>

BrowserUK suggested some code on 26 February 2013 but I find it very difficult to understand right from the beginning. I am little acuainted with #!/usr/bin/perl and not with others. That is why I am now trying with Algorithm::Permute module to solve the problem. I am looking forward to suggestions from PerlMonks to fix the problem of try5.pl in my computer.

Replies are listed 'Best First'.
Re: How can I fix the problem in using the Algorithm::Permute module?
by Corion (Patriarch) on Feb 27, 2013 at 07:43 UTC

    It seems that your installation of Algorithm::Permute was incomplete. Perl does not find required parts of the module installation.

    How did you install Algorithm::Permute?

    You will need to properly install the module, either using the ppm tool or using the cpan tool. You can try to force reinstallation by using

    cpan -f Algorithm::Permute

    Simply copying some files manually is not a proper installation procedure.

      Hi Corion,

      Thank you very much for your valuable suggestions. I have reinstalled Algorithm::Permute as per your advice. It has worked and solved my problem.

      With kind regards.

Re: How can I fix the problem in using the Algorithm::Permute module?
by Khen1950fx (Canon) on Feb 27, 2013 at 08:13 UTC
    You almost had it. You just need to add brackets and declare @res:
    #!/usr/bin/perl -l use strict; use warnings; use Algorithm::Permute; my(@arr) = qw/A B C/; my $p = new Algorithm::Permute([@arr], 2); while (my(@res) = $p->next) { do { print join(", ", @res); }; } exit 0;

      Hi Khen1950fx,

      Thank you very much for prompt reply. The code has worked and solved my problem. Sometimes I feel that the Perlmonks are very helpful and try to sort out the problems of the person like me who has no formal training in computer or its languages. This is highly appreciable.

      With deep Regards

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1020812]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found