http://qs321.pair.com?node_id=607748


in reply to Re^2: Permuting with duplicates and no memory
in thread Permuting with duplicates and no memory

Just FYI, perhaps you missed this bit from the root node:

do { print "@ARGV\n"; } while( nextPermut­e(@ARGV) );

which is also why I called my routine "nextPermute".

Also note that dragonchild's and my iterators can be reused. For yours to be reusable you probably want to change:

return if $i == -1;

to

if( $i == -1 ) { $first= 1; return; }

- tye