sub maxprefix { my $p = shift; for (@_) { chop $p until /^\Q$p/ } return $p; }