Hi
I'm using File::Find to recursively get all the files from a directory
structure, then splitting each $File::Find::name into an array.
What I need to do is put this into a data structure like:
$dirstruct{"mydir"}->{dir1}->{dir2}->["A.A","B.B"]
$dirstruct{"mydir"}->{dir1}->{dir3}->{dir4}->["C.C","D.D"]
$dirstruct{"mydir"}->{dir4}->{dir5}->["E.E"]
The directory listing would be:
/dir1/dir2/A.A
/dir1/dir2/B.B
/dir1/dir3/dir4/C.C
/dir1/dir3/dir4/D.D
/dir4/dir5/E.E
I know I've done this before, but I'll be damned if I can find it or
remember how I did it.
<perl>
my $directory = '\\gbu'; # Sorry it's on Windows!
find(\&getfiles, $directory);
getfiles($directory);
sub getfiles {
my $file = $File::Find::name;
return if (! $file);
if (-f $file) {
$file =~ s/^\\//g;
my @fp = split(/\//,$file);
# Somehow need to get this into %DIRSTRUCT!!
...<insert code here :)>
}
}
</perl>
Please Help!
TIA
Andy
============================================================
"This sounds like a twelve-change-of-underwear trip."
============================================================