use strict; use warnings; my $folder_path = "/aboutiso/corp_gov/bod/agendas/2010"; $folder_path =~ s#((/\w+)+)/\w+$#$1#; print "folderpath: $folder_path\n";