$str = "/dir1/dir2/dir3/file.txt";$str =~ s/(.*)\/[^\/]*$//;print "Result: '$1'";
Standard input is empty
Result: '/dir1/dir2/dir3'
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!