See File::Basename respectively File::Spec->splitpath.
In reply to Re: Get last occurence of a character in a string by Corion in thread Get last occurence of a character in a string by theroninwins