in reply to Re^2: How to cut the directory path?
in thread How to cut the directory path?

If you really want to use regex, you could do this:
my $filespec = "/usr/share/directory/piano_book.mp4"; my $relative = "." . $1 if $filespec =~ m{/usr/share(.*)};
Or you could use split and then paste together the pieces you need.

But you'd most probably be better off with a specialized module such as Path::Tiny mentioned above or some other.