I am new to perl scripting. Can some one tell me how to find the last indexof substring in a string which is repeat several times in the string.
Actully I want to extract the file name from a give path
$outFile = "C:\\AOTITS\\BackOffice\\CSVFiles\\test.txt";
If I can find the last string of the '\' I cand extract the file name using substr
function. I already did that in the following way. But it is inefficient.
$fragment = $outFile ;
$count = index($fragment, "\\");
while($count > -1) {
$fragment = substr ($fragment, index($fragment, '\\')+1);
$count = index($fragment, '\\');
}
Can some one tell me a way to do that in a efficient way.