>>9
ヒント:

($parent = $name) =~ s#/[^/]+$##;

これは以下のコードとほぼ同じ

$parent = $name;
$patent =~ s/[^\/]+$//;