my $plsname = $curdir; $plsname =~ s[^\Q$startdir\E\\(.+)$][$1.pls]i; $plsname =~ tr[\\][_]; print $plsname;; Schubert_Lieder_Terfel.pls