$filename=~ s/\//_/g; #replace all / with _
$filename = reverse $filename; #reverse the file name so we can get rid of the leading _
chop $filename; #get rid of the last _, which is really the first _
$filename = reverse $filename; #get it back to the original filename, instead of backwards.
why?
$filename=~ s/\//_/g; #replace all / with _
$filename=~ s/^_//; #replace the leading _
I don't like using chop because it just drops the last character ... it doesn't care if that character is actually what you wanted to drop ...
perldoc says: "It is much more efficient than 's/.$//s' because it neither scans nor copies the string."
but you reverse the string twice and I think that probably removes any advantage there may have been ...
Just a comment ... if you disagree, I'd liked to hear your reasoning for my own benefit ... I learn something new every day
