fork download
  1. $str = "/dir1/dir2/dir3/file.txt";
  2. $str =~ s/(.*)\/[^\/]*$//;
  3. print "Result: '$1'";
  4.  
Success #stdin #stdout 0s 4596KB
stdin
Standard input is empty
stdout
Result: '/dir1/dir2/dir3'