my $folder_path = "/aboutiso/corp_gov/bod/agendas/2010/"; my $try = "index.html"; my $test = "$folder_path/$try"; $folder_path =~ s#/\w+/[^/]*.\w+$##; print "folderpath: $folder_path\n"; ^D folderpath: /aboutiso/corp_gov/bod/agendas/2010/ #### my $folder_path = "/aboutiso/corp_gov/bod/agendas/2010/"; my $try = "index.html"; my $test = "$folder_path/$try"; print "folderpath: $test\n"; $test =~ s{/+\w+/+\w+\.\w+$}{}; print "folderpath: $test\n"; ^D folderpath: /aboutiso/corp_gov/bod/agendas/2010//index.html folderpath: /aboutiso/corp_gov/bod/agendas