in reply to Get last occurence of a character in a string
XY Problem. What you really want is File::Basename which will do this (in a platform independent fashion, even).
The cake is a lie. The cake is a lie. The cake is a lie.