in reply to Advanced array permutation

Worked like a charm. Thanks tye.
I'm still a bit of a novice to perl so I have one more basic question to your solution. I usually place my subroutines below my main code. When I did this with your code, it did not work. Only when I placed it above the main code it worked.
What's the reasoning behind the madness?
Thanks,
Avi

Replies are listed 'Best First'.
Re: Re: Advanced array permutation
by dragonchild (Archbishop) on Mar 20, 2002 at 14:38 UTC
    tye's solution uses prototypes. Because it does, it must be declared above where it is used. You can either define it above the usage or just declared it above, as seen here:
    sub foo (@$); .... # Some usage of foo() here .... sub foo (@$) { # Blah blah blah }

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Alternately, you can delete the prototype and pass in a reference to the array directly: nextpermute(\@list).

      BTW, Avi, next time, if you reply to my (or whoever's) node rather than to your original question, you are likely to get a faster answer as I get notified of replies to my nodes (see User Settings).

              - tye (but my friends call me "Tye")