Re: algorithm permute
Tom & Jay, Thanks a lot. Actually the user is same. I have confirmed again. I know it irritates a lot when a help seeker posts incorrect data and requests support. But in this case, the user is same. I have not gone deep into the issue. But the distinct difference is that in the terminal where it works, I have not sourced scripts that I usually do for my day to day work (paths to tools etc. Some tools use perl) Needless to say, on the terminal where it works, the scripts are not sourced. I did try to echo PERL5LIB and see if that is the source of confusion, but it is undefined in all the terminals. perldoc -l Algorithm::Permute yields No documentation found for "Algorithm::Permute". Anyway, now I know how to make it work consistently. My initial hunch was that something to do with a variable that was set on the shell prompt and hence got lost for some reason later. Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
On Mon, Nov 17, 2008 at 10:13 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: >> >> You haven't installed anything. You've downloaded and untarred/ >> gunzipped the source. You still have to run >> perl Makefile.PL >> make >> make test >> make install >> >> That final command will copy the installed module to the real library >> directory. THAT is the path that you need for use lib. >> >> perldoc perlmod >> for more information >> >> Paul Lalli > > I would like to rewind a bit and see why this could be happening. I am > really curious about this. > As I mentioned in my original mail, a working file stopped all of a sudden. > Now I have 3 terminals open. All 3 are on same machine .. > > I have done uname -a to confirm this. > In 2 terminals, the script errors out with: > perl StTrAuto.pl > Can't locate Algorithm/Permute.pm in @INC (@INC contains: > /u/basappas/local/perl/perm_install/lib/perl5/site_perl > /hwnet/activestate/perl-5.6/lib/5.6.1/i686-linux-thread-multi > /hwnet/activestate/perl-5.6/lib/5.6.1 > /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi > /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1 > /hwnet/activestate/perl-5.6/lib/site_perl .) at StTrAuto.pl line 5. > BEGIN failed--compilation aborted at StTrAuto.pl line 5. > > On the 3 rd terminal, it works fine. > > The machine is same, the script is same. What about user? You clearly have different configurations for the different sessions, the question is why. I've seen two different user names appear in the @INC and use lib paths you you've posted to the group. My suspicion is that you've installed the module as one user, but then tried to run the script as another. since you're installing the modules to local directories as an unprivileged user rather than the to global perl /lib directories as a superuser, you're having path and permissions issues. It also appears that you have installed the Algorithm::Permute module for the default Perl 5.8.5 installation on your machine, but your problematic scripts are invoking an Active State Perl 5.6 that you have installed in a non-standard location. If you're going to use multiple versions of Perl on the same machine, you need to be very careful about choosing the right combination of interpreters and modules for each script. HTH, -- jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!
Re: algorithm permute
On Mon, Nov 17, 2008 at 7:13 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: > On the 3 rd terminal, it works fine. So, on the third terminal, you can ask it which module it is finding that the others aren't: perldoc -l Algorithm::Permute > I ran "env" and redirected output to a file from 2 terminals. There > are lot of differences. PERL5LIB, perhaps? You can use that environment variable to try out a module without installing it "for real". Another one to check is PATH; you could be using a different perl binary without realizing it. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
> > You haven't installed anything. You've downloaded and untarred/ > gunzipped the source. You still have to run > perl Makefile.PL > make > make test > make install > > That final command will copy the installed module to the real library > directory. THAT is the path that you need for use lib. > > perldoc perlmod > for more information > > Paul Lalli I would like to rewind a bit and see why this could be happening. I am really curious about this. As I mentioned in my original mail, a working file stopped all of a sudden. Now I have 3 terminals open. All 3 are on same machine .. I have done uname -a to confirm this. In 2 terminals, the script errors out with: perl StTrAuto.pl Can't locate Algorithm/Permute.pm in @INC (@INC contains: /u/basappas/local/perl/perm_install/lib/perl5/site_perl /hwnet/activestate/perl-5.6/lib/5.6.1/i686-linux-thread-multi /hwnet/activestate/perl-5.6/lib/5.6.1 /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1 /hwnet/activestate/perl-5.6/lib/site_perl .) at StTrAuto.pl line 5. BEGIN failed--compilation aborted at StTrAuto.pl line 5. On the 3 rd terminal, it works fine. The machine is same, the script is same. I ran "env" and redirected output to a file from 2 terminals. There are lot of differences. By now, I am pretty sure this is the cause for the script failing. But there are so many differences I am not able to make out what variable is causing script to konk. Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
On Nov 13, 10:26 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: > Just an update. I have installed to a new location and can see the > following files > > /u/basappas/local/perl/Algorithm-Permute-0.06/ > Algorithm Changes Makefile.PL Perm2.pl Permute.o pm_to_blib typemap > bench lib MANIFEST Permute.bs Permute.pm share > blib Makefile META.yml Permute.c Permute.xs test.pl You haven't installed anything. You've downloaded and untarred/ gunzipped the source. You still have to run perl Makefile.PL make make test make install That final command will copy the installed module to the real library directory. THAT is the path that you need for use lib. perldoc perlmod for more information Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
2008/11/13 Sharan Basappa <[EMAIL PROTECTED]>: > Just an update. I have installed to a new location and can see the > following files > > /u/basappas/local/perl/Algorithm-Permute-0.06/ > Algorithm Changes Makefile.PL Perm2.plPermute.o pm_to_blib typemap > bench lib MANIFEST Permute.bs Permute.pm share > blib Makefile META.yml Permute.c Permute.xs test.pl > > I put this path in my code use lib > "/u/basappas/local/perl/Algorithm-Permute-0.06" > and still see the error: > Can't locate loadable object for module Algorithm::Permute in @INC > (@INC contains: /u/basappas/local/perl/Algorithm-Permute-0.06 > /hwnet/activestate/perl-5.6/lib/5.6.1/i686-linux-thread-multi > /hwnet/activestate/perl-5.6/lib/5.6.1 > /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi > /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1 > /hwnet/activestate/perl-5.6/lib/site_perl .) at Perm2.pl line 4 > Compilation failed in require at Perm2.pl line 4. > BEGIN failed--compilation aborted at Perm2.pl line 4 > > Am I missing something really? (like setting path to perl_lib) Yes you would need to set @INC to include '/u/basappas/local/perl/' not /u/basappas/local/perl/Algorithm-Permute-0.06 But this doesn't look right! You have downloaded the source to /u/basappas/local/perl/Algorithm-Permute-0.06 but you need to build it. I can't see a README or INSTALL file in that distribution listing. That's odd. You may have to edit the Makefile manually to install it in a path you have access to. Good luck, Dp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
Just an update. I have installed to a new location and can see the following files /u/basappas/local/perl/Algorithm-Permute-0.06/ Algorithm Changes Makefile.PL Perm2.plPermute.o pm_to_blib typemap bench lib MANIFEST Permute.bs Permute.pm share blib Makefile META.yml Permute.c Permute.xs test.pl I put this path in my code use lib "/u/basappas/local/perl/Algorithm-Permute-0.06" and still see the error: Can't locate loadable object for module Algorithm::Permute in @INC (@INC contains: /u/basappas/local/perl/Algorithm-Permute-0.06 /hwnet/activestate/perl-5.6/lib/5.6.1/i686-linux-thread-multi /hwnet/activestate/perl-5.6/lib/5.6.1 /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1/i686-linux-thread-multi /hwnet/activestate/perl-5.6/lib/site_perl/5.6.1 /hwnet/activestate/perl-5.6/lib/site_perl .) at Perm2.pl line 4 Compilation failed in require at Perm2.pl line 4. BEGIN failed--compilation aborted at Perm2.pl line 4 Am I missing something really? (like setting path to perl_lib) Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
On Mon, Nov 10, 2008 at 12:36, Paul Lalli <[EMAIL PROTECTED]> wrote: snip > "elsewhere" is the problem. Algorithm::Permute is not a built-in > module. You have to install it manually via the CPAN on every machine > you want to use it. snip Another option (if installing modules is, for some reason, impossible) is to use PAR::Packer* to make a standalone executable out of your script. * http://search.cpan.org/dist/PAR-Packer/lib/PAR/Packer.pm -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
Hi Paul, Regards On Mon, Nov 10, 2008 at 11:06 PM, Paul Lalli <[EMAIL PROTECTED]> wrote: > On Nov 10, 9:15 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: >> Hi, >> >> After working fine with Algorithm::Permute module for weeks now, >> suddenly I seem to be getting errors. >> >> The particular error is: >> $ perl StTrAuto.pl >> Can't locate Algorithm/Permute.pm in @INC (@INC contains: >> /u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at >> StTrAuto.pl line 4. >> BEGIN failed--compilation aborted at StTrAuto.pl line 4. >> >> First few lines of code which I thought are causing the issue: >> 1 #!/usr/bin/perl >> 2 use warnings; >> 3 use lib "/u/sharan/local/perl/perm_install/lib/perl5/site_perl"; >> 4 use Algorithm::Permute; >> >> The interesting thing is that I have an example code elsewhere and >> that works fine. >> Again, the first few lines of code from example: >> >> #!/usr/bin/perl >> use warnings; >> use lib >> "/u/sharan/local/perl/perm_install/lib/perl5/site_perl"; >> use Algorithm::Permute; >> >> my @array = (1..4); >> Algorithm::Permute::permute { print "@array\n" } @array; >> [EMAIL PROTECTED] = Algorithm::Permute::permute (@array); >> >> Any clues" > > > "elsewhere" is the problem. Algorithm::Permute is not a built-in > module. You have to install it manually via the CPAN on every machine > you want to use it. Whatever machine you're currently using, you > haven't installed it - or at the very least, you haven't installed it > to "/u/sharan/local/perl/perm_install/lib/perl5/site_perl". Try > running > find / -name Permute.pm 2> /dev/null > to see where, if at all, the module is located on this system. Hi Paul, Its the same machine. The only difference is that the directory from where I run my actual code is different from the example code. I tried it again to make sure this is the case. When I put a find after the path I have included in use lib, I get the following result: ./5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm ./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm ./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5 /i386-linux-thread-multi/Algorithm/Permute.pm ./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5 /i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/Algorithm/Permute.pm ./5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5 /i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-linux-thread-multi/perl5/site_perl/5.8.5/i386-l inux-thread-multi/Algorithm/Permute.pm Ok, let me try installing fresh once again and see if that helps ... Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: algorithm permute
On Nov 10, 9:15 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: > Hi, > > After working fine with Algorithm::Permute module for weeks now, > suddenly I seem to be getting errors. > > The particular error is: > $ perl StTrAuto.pl > Can't locate Algorithm/Permute.pm in @INC (@INC contains: > /u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at > StTrAuto.pl line 4. > BEGIN failed--compilation aborted at StTrAuto.pl line 4. > > First few lines of code which I thought are causing the issue: > 1 #!/usr/bin/perl > 2 use warnings; > 3 use lib "/u/sharan/local/perl/perm_install/lib/perl5/site_perl"; > 4 use Algorithm::Permute; > > The interesting thing is that I have an example code elsewhere and > that works fine. > Again, the first few lines of code from example: > > #!/usr/bin/perl > use warnings; > use lib > "/u/sharan/local/perl/perm_install/lib/perl5/site_perl"; > use Algorithm::Permute; > > my @array = (1..4); > Algorithm::Permute::permute { print "@array\n" } @array; > [EMAIL PROTECTED] = Algorithm::Permute::permute (@array); > > Any clues" "elsewhere" is the problem. Algorithm::Permute is not a built-in module. You have to install it manually via the CPAN on every machine you want to use it. Whatever machine you're currently using, you haven't installed it - or at the very least, you haven't installed it to "/u/sharan/local/perl/perm_install/lib/perl5/site_perl". Try running find / -name Permute.pm 2> /dev/null to see where, if at all, the module is located on this system. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
algorithm permute
Hi, After working fine with Algorithm::Permute module for weeks now, suddenly I seem to be getting errors. The particular error is: $ perl StTrAuto.pl Can't locate Algorithm/Permute.pm in @INC (@INC contains: /u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at StTrAuto.pl line 4. BEGIN failed--compilation aborted at StTrAuto.pl line 4. First few lines of code which I thought are causing the issue: 1 #!/usr/bin/perl 2 use warnings; 3 use lib "/u/sharan/local/perl/perm_install/lib/perl5/site_perl"; 4 use Algorithm::Permute; The interesting thing is that I have an example code elsewhere and that works fine. Again, the first few lines of code from example: #!/usr/bin/perl use warnings; use lib "/u/sharan/local/perl/perm_install/lib/perl5/site_perl"; use Algorithm::Permute; my @array = (1..4); Algorithm::Permute::permute { print "@array\n" } @array; [EMAIL PROTECTED] = Algorithm::Permute::permute (@array); Any clues" Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using algorithm-permute
On Wed, Oct 22, 2008 at 4:32 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: > Sharanbr wrote: >> On Oct 19, 6:38 am, [EMAIL PROTECTED] (Sisyphus) wrote: >>> On Oct 17, 3:04 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: >>>> >>>> #!/usr/bin/perl >>>> use warnings; >>>> use Algorithm::Permute; >>>> my @array = (1..4); >>>> Algorithm::Permute::permute { print "@array\n" } @array; >>> >>> use warnings; >>> use strict; >>> use Algorithm::Permute; >>> >>> my @array = (1..9); >>> my $p = new Algorithm::Permute([EMAIL PROTECTED]); >>> >>> # print out the first 20 permutations of @array, >>> # assigning each permutation to @new, and >>> # printing it out: >>> for(1..20) { >>> my @new = $p->next; >>> print "@new\n"; >>> >>> } >> >> I have modified the code a little bit to suit my requirements. But >> still the code does not seem to work i.e. >> the final print of @x does not display any value. However, I change >> the code foreach (@array) to for (1..) >> the way you have coded, it works fine. My requirement is to put all >> the permutations into a new array, >> not just (1..20) >> >> I have another basic doubt. After permute is called with @array >> argument, does it now contain >> new permutations or still (1..4). >> >> #!/usr/bin/perl >> use warnings; >> use Algorithm::Permute; >> >> my @array = (1..4); >> my $p = new Algorithm::Permute([EMAIL PROTECTED]); >> foreach (@array) >> { >> my @x = $p->next; >> print "@x \n"; >> } > > You shouldn't pass a real array to the 'new' method as it destroys the array. > It's bad but there it is, and the documentation does show it being called with > an anonymous array. > > I'm not sure what you mean by 'put all the permutations into a new array', as > each permutation is held in an array and I'm guessing that you don't know > about > arrays of arrays? > > The program I've written below stores each permutation as a single string with > spaces between the elements. If you really do want a array of arrays instead > of > an array of strings then it's very obvious how to modify it to do that. > > HTH, > > Rob > > > use strict; > use warnings; > > use Algorithm::Permute; > > my $p = Algorithm::Permute->new([1 .. 4]); > > my @permutations; > > while (my @array = $p->next) { > push @permutations, "@array"; > } > > print "$_\n" foreach @permutations; > Thanks, Rob. The method works and also fits in the overall code I am writing. The main reason for confusion from my side is my lack of understanding of how different methods of algo permute work (e.g. I was not aware that an anonymous array was created. I was thinking that the original array is modified to create permutations. Lack of good doc also contributed to this confusion. Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using algorithm-permute
Sharanbr wrote: > On Oct 19, 6:38 am, [EMAIL PROTECTED] (Sisyphus) wrote: >> On Oct 17, 3:04 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: >>> >>> #!/usr/bin/perl >>> use warnings; >>> use Algorithm::Permute; >>> my @array = (1..4); >>> Algorithm::Permute::permute { print "@array\n" } @array; >> >> use warnings; >> use strict; >> use Algorithm::Permute; >> >> my @array = (1..9); >> my $p = new Algorithm::Permute([EMAIL PROTECTED]); >> >> # print out the first 20 permutations of @array, >> # assigning each permutation to @new, and >> # printing it out: >> for(1..20) { >> my @new = $p->next; >> print "@new\n"; >> >> } > > I have modified the code a little bit to suit my requirements. But > still the code does not seem to work i.e. > the final print of @x does not display any value. However, I change > the code foreach (@array) to for (1..) > the way you have coded, it works fine. My requirement is to put all > the permutations into a new array, > not just (1..20) > > I have another basic doubt. After permute is called with @array > argument, does it now contain > new permutations or still (1..4). > > #!/usr/bin/perl > use warnings; > use Algorithm::Permute; > > my @array = (1..4); > my $p = new Algorithm::Permute([EMAIL PROTECTED]); > foreach (@array) > { > my @x = $p->next; > print "@x \n"; > } You shouldn't pass a real array to the 'new' method as it destroys the array. It's bad but there it is, and the documentation does show it being called with an anonymous array. I'm not sure what you mean by 'put all the permutations into a new array', as each permutation is held in an array and I'm guessing that you don't know about arrays of arrays? The program I've written below stores each permutation as a single string with spaces between the elements. If you really do want a array of arrays instead of an array of strings then it's very obvious how to modify it to do that. HTH, Rob use strict; use warnings; use Algorithm::Permute; my $p = Algorithm::Permute->new([1 .. 4]); my @permutations; while (my @array = $p->next) { push @permutations, "@array"; } print "$_\n" foreach @permutations; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using algorithm-permute
On Oct 19, 6:38 am, [EMAIL PROTECTED] (Sisyphus) wrote: > On Oct 17, 3:04 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: > . > . > > > > > #!/usr/bin/perl > > use warnings; > > use Algorithm::Permute; > > my @array = (1..4); > > Algorithm::Permute::permute { print "@array\n" } @array; > > use warnings; > use strict; > use Algorithm::Permute; > > my @array = (1..9); > my $p = new Algorithm::Permute([EMAIL PROTECTED]); > > # print out the first 20 permutations of @array, > # assigning each permutation to @new, and > # printing it out: > for(1..20) { > my @new = $p->next; > print "@new\n"; > > } > > Cheers, > Rob Thanks, Rob I have modified the code a little bit to suit my requirements. But still the code does not seem to work i.e. the final print of @x does not display any value. However, I change the code foreach (@array) to for (1..) the way you have coded, it works fine. My requirement is to put all the permutations into a new array, not just (1..20) I have another basic doubt. After permute is called with @array argument, does it now contain new permutations or still (1..4). #!/usr/bin/perl use warnings; use Algorithm::Permute; my @array = (1..4); my $p = new Algorithm::Permute([EMAIL PROTECTED]); foreach (@array) { my @x = $p->next; print "@x \n"; } Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using algorithm-permute
On Oct 17, 3:04 am, [EMAIL PROTECTED] (Sharan Basappa) wrote: . . > > #!/usr/bin/perl > use warnings; > use Algorithm::Permute; > my @array = (1..4); > Algorithm::Permute::permute { print "@array\n" } @array; use warnings; use strict; use Algorithm::Permute; my @array = (1..9); my $p = new Algorithm::Permute([EMAIL PROTECTED]); # print out the first 20 permutations of @array, # assigning each permutation to @new, and # printing it out: for(1..20) { my @new = $p->next; print "@new\n"; } Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
using algorithm-permute
Hi, I need to create permutations of a given set of values. The set is itself present in an array. From this I am trying to create another array that has permutations of this set. I am able to create a small example and run but from the description of the module I am not sure how to put the permutations into another array. Can someone tell me how the code given below can be modified. PS: I am not well versed with perl classes Regards, #!/usr/bin/perl use warnings; use Algorithm::Permute; my @array = (1..4); Algorithm::Permute::permute { print "@array\n" } @array; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/