in reply to How to cut the directory path?

If what is wanted is really the lowest level directory plus file name, try this:

my $filespec = '/usr/share/directory/piano_book.mp4'; my @parts = split /\//, $filespec; my $relative = './' . join '/', splice @parts,-2,2;
But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)