in reply to Deleting folders based on name.

I presume there are some typos here with the superfluous colons:

my($hf) = File::Util->;new(); my(@HighFolders) = $hf->;list_dir($Highpath,'--dirs-only');

If I follow you properly, you might want to make one single datastructure here -- each element of the "Highfolders" array would be an array reference. The first element of that array (0) would be the MMYY name, the second element (1) would be another array reference to an array containing the subfolders. I think this would eliminate the need for unique names (unless there is some further reason for that). Might look something like:

#!/usr/bin/perl -w use strict; use File::Util; my $hf = File::Util->new(); my $path = '/'; my @Folders; foreach ($hf->list_dir($path,'--dirs-only')) { my @tmp = $_; push @Folders, \@tmp; # the outer array ref } foreach (@Folders) { my $lf = File::Util->new(); my @tmp = $lf->list_dir($path.$_->[0],'--dirs-only'); $_->[1] = \@tmp; # inner array ref } # verify: foreach (@Folders) { print $_->[0]."\n"; foreach my $sub (@{$_->[1]}) { print "\t$sub\n"; } }

I haven't used File::Util before so I inferred from your code, but I did test this -- I hope that's kinda what you are looking for. It's nice to comment on datastructures like this in the code, eg:

my @Folders; # array of array refs, each sub-array = # 0: directory name # 1: array of subdirectories