in reply to Re^3: finding the path of the script running as Win service
in thread finding the path of the script running as Win service

Substitute, matching on the last '\' character, followed by any amount (or nothing at all) of non '\' characters. Replace with nothing. Essentially, this strips away the filename and final '\' character, on a system where '\' is the path separator.
Thanks Davido for a nice explanation. The above is the only part that is confusing me. Shouldn't the entire pattern be grouped as in s/(\\[^\\]*)$// otherwise what prevents the above from catching everything starting from the very first \ all the way to the end?

Note: File::Basename does not work in my situation because of the Win service involved. See my OP above.