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

I have a series of numbers in a file (ex. 1 9 2 8 3 7 4 6 5 10) and I need to list all of the combinations of a subset of these numbers. I imported the numbers from the file into an array (@numbers) and then tried to use the Algorithm::Combinatorics combinations function, but I can't get it to read the actual numbers in my array. In all of the examples they create the initial array using @array = qw(1 2 3 4 5) etc. My file is too long to organize it this way, but when I input my array using the instructions in the module it just reads the combinations as "ARRAY(0x22180f4)" etc. How do I get it to read my array? Thanks

Replies are listed 'Best First'.
Re: Longest Increasing Subset
by Anonymous Monk on Oct 12, 2016 at 23:56 UTC
    Just a guess, but maybe you're just not looking at the return value the right way.
    my $iter = permutations(\@data); while (my $p = $iter->next) { print "@$p\n"; }
    Trouble is, this will take a VERY long time to complete if @data is large.
      perfect! Thanks, that solved my issue
Re: Longest Increasing Subset
by BrowserUk (Patriarch) on Oct 12, 2016 at 21:23 UTC

    Show your code, we can correct it for you.

Re: Longest Increasing Subset
by tybalt89 (Monsignor) on Oct 13, 2016 at 00:31 UTC

    Please show what output you expect from your example 1 9 2 8 3 7 4 6 5 10.