$str1="/fold1/fold2/fold3/file.pl" DB<48> p $str1 /fold1/fold2/fold3/file.pl DB<49> if ($str1 =~ m#([^/]+)$#) { print $1;} file.pl <<<< I managed to get my file name but need to get rest of the path. DB<50>