use File::Spec (); my ($subdir1) = (File::Spec->splitdir(File::Spec->rel2abs($_)))[2];