dsb has asked for the wisdom of the Perl Monks concerning the following question:
The variable that has the data structure of element sets is '$pairs'(a hash of arrays). When I call this routine I pass it 3 args: 2 arrayrefs, and the scalar hashref. Just before the 'unless' statement, $pairs is defined and houses all the right data. Inside the branch that is executed if the condition is met, $pairs is all of a sudden empty.
sub permute { my @items = @{ $_[0] }; my @perms = @{ $_[1] }; my $pairs = $_[2]; # here its defined unless (@items) { my $phrase = join( " ", @perms ); print $pairs, "\n"; exit; # here its empty all of sudden my $res = check_ord( $phrase, $pairs ); if ( !( $res ) ) { # $ARGV[0] ? print FH $phrase. "\n" : print $phrase, "\n"; } } else { my(@newitems,@newperms,$i); foreach $i (0 .. $#items) { @newitems = @items; @newperms = @perms; unshift(@newperms, splice(@newitems, $i, 1)); permute([@newitems], [@newperms]); } } }
Any ideas?
Amel - f.k.a. - kel
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Defined or Undefined - That is the question.
by enoch (Chaplain) on Mar 13, 2001 at 20:26 UTC | |
by michael (Sexton) on Mar 13, 2001 at 21:51 UTC | |
by sacked (Hermit) on Mar 14, 2001 at 04:29 UTC | |
by michael (Sexton) on Mar 14, 2001 at 06:07 UTC | |
| |
|
Re: Defined or Undefined - That is the question.
by dsb (Chaplain) on Mar 13, 2001 at 20:25 UTC | |
by $code or die (Deacon) on Mar 13, 2001 at 21:27 UTC |