$path =~ s{/$}{} if $path ne "/"; # hack to make splitpath give us a basename