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