in reply to Capturing Base Name of a File With or Without Path

Just use $1 if found the regex;
sub get_basename {return $1 if shift =~ /(\w+)(\.\w+)?$/}