$hash{subdir 1} $hash{subdir 2}{subsubdir 2.1} $hash{subdir 2}{subsubdir 2.2} $hash{subdir 3}{subsubdir 3.1} $hash{subdir 3}{subsubdir 3.1}{subsubsubdir 3.1.1} $hash{subdir 3}{subsubdir 3.1}{subsubsubdir 3.1.2} $hash{subdir 3}{subsubdir 3.1}{subsubsubdir 3.1.3} #### @parts=split /\//,$dirname; %hash{ @parts } = (); ## this doesn't work, of course, ## just an example of the idea #### $hash{foo}=1; $hash{foo}{bar}=2; #### #!/usr/bin/perl use strict; use Data::Dumper; my %hash; $hash{foo}=[undef,1]; $hash{foo}[0]{bar}=[undef,2]; $hash{foo}[0]{bar}[0]{bink}=[undef,4]; print Dumper \%hash;