sub of { my $x = shift; my @y = map { $_-1 if defined && /^\d+$/ && $_>0 } @_; # protect the caller from placement errors return undef unless ($#y == $#_); return map { ($_<$$x{'n'}) ? $$x{'perm'}[$_] + 1 : $_+1 } @y; }