I am new to perl scripts. Can someone tell me how to find the last index of a substring in a string that repeats several times in a string.
Actully I want to extract the file name from the transfer path
$outFile = "C:\\AOTITS\\BackOffice\\CSVFiles\\test.txt";
If I can find the last line '\', I want to extract the file name using the function substr. I already did it as follows. But it is inefficient.
$fragment = $outFile ;
$count = index($fragment, "\\");
while($count > -1) {
$fragment = substr ($fragment, index($fragment, '\\')+1);
$count = index($fragment, '\\');
}
Can someone tell me a way to do this in an efficient way.
source
share