package Math_Set; $VERSION="1.00"; sub minimal { my ($array) = @_; # Pass by reference my $i=0; my $j; while ( $i < $#{$array} ) { $j = $i+1; while ( $j <= $#{$array} ) { #print "\${\$array[$i] = ${$array}[$i] \n"; #print "\${\$array[$j] = ${$array}[$j] \n"; #print "len(array) = " . scalar(@{$array}) . "\n"; if ( ${$array}[$i] eq ${$array}[$j] ) { # Remove j element #print "Removed $j element\n"; splice @{$array} , $j, 1; # Decrement j since we just removed an element # and it will be incremented again at the end of the while $j--; } $j++; } $i++; } }#end minimal_set return 1;