# this is NOT tested my ($vol, $dir, $file) = File::Spec::splitpath($path); my $temp_path = $path; my $temp_dir; my $temp_vol; my @dirs; while ($dir neq $temp_path) { $temp_path = $dir; ($temp_vol, $dir, $temp_dir) = File::Spec::splitpath($temp_path); unshift @dirs, $temp_dir; } unshift(@dirs, $dir) unless (@dirs > 0);