in reply to Need to capture an optional sub-directory name

but I am no regex pro

You don't need to become a "regex pro" -- whatever one of those is -- but you would sure save yourself some time in the long run, by making the effort to learn the basics:

$p = 'C:\Tools\scripts\Test\Unstable\Foo.pl';; $p =~ s[C:\\Tools\\scripts\\([^.]+).pl][$1]; $p =~ s[\\][ - ]g; print $p;; Test - Unstable - Foo $p2 = 'C:\Tools\scripts\Test\Foo.pl';; $p2 =~ s[C:\\Tools\\scripts\\([^.]+).pl][$1]; $p2 =~ s[\\][ - ]g; print $p2;; Test - Foo

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?