#!/usr/bin/perl -w use strict; use File::Spec::Win32; use Data::Dumper; my %h_dirs; while (){ chomp; my ($vol, $dirs, $file) = File::Spec::Win32->splitpath($_); $h_dirs{ $dirs }++ unless $file ; } print Dumper \%h_dirs; __DATA__ \windows\server\locales\en_US\help\whxdata\whftdata0.xml \windows\server\locales\en_US\help\whxdata\ \windows\server\locales\en_US\help\whxdata\whfwdata0.xml \windows\server\locales\en_US\help\whxdata\whfwdata1.xml \windows\server\locales\en_US\help\whxdata\whfwdata2.xml \windows\server\locales\en_US\help\whxdata2\