sub prefix { my $prefix = shift; for (@_) { next if $prefix eq substr($_, 0, length $prefix); chop $prefix; redo; } $prefix; }