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/