sub new { # SNIP # BEGIN vicious error checking # all input must be legitimate $x{'perm'}=[ map { $_-1 if defined and /^\d+$/ and $_ > 0} @_ ]; return undef unless $#{$x{'perm'}} == $#_; # it must really be a permutation of 0..n-1 return undef unless join(' ',sort { $a <=> $b } @{$x{'perm'}}) eq join(' ',0..$#{$x{'perm'}}); # END error checking # SNIP $x{'n'} = scalar @{$x{'perm'}}; # for clarity in other places bless \%x, $class; }