Help for this page
$directory =~ s<^/*></> . </*$></>;
$directory =~ s< ^ /? # match leading '/' if present ... /? $ # match trailing '/' > </$1/>x; # now surround the middle with '/'