+sub path_key ($) {
+ my ($p) = @_;
+ if ($p =~ m{^ ([a-z]) / ([^/]+) ((?: / .*)?) $}ix) {
+ my $init = $1;
+ my $focus = $2;
+ my $tail = $3;
+ my $head = undef;
+ if ($focus =~ /^ (the | a ) \s+ (\S .*) $/x)
+ { $head = $1; $focus = $2; }
+ if (lc $init ne lc substr($focus, 0, 1) &&
+ $focus =~ /^ (.*) \s+ ($init .*) $/x)
+ { $head .= (defined $head && " ") . $1; $focus = $2; }
+ if (defined $head) { return "$init/$focus, $head$tail"; }
+ }
+ return $p;
+}
+