David Cantrell wrote:
> # untested code
> $file=~!(.*)/(.*)!;
> ($dir, $file)=($1, $2); # Get the directory and filename portions
> # there's a module to do that, but I can't remember what it's called
File::Basename, probably. Or maybe File::Spec->splitdir().
> $dir=~s!/!}{!; $dir='{'.$dir.'}'; # now looks like {dir1}{dir2}
> eval('$dirstruct{mydir}'.$dir.'=$file'); # Hah! Just you try
> that in C!
>
> Adapting this for systems which use different directory seperators and
> making it store more than one file per directory is left as a trivial
> exercise for the reader :-)
The second is easy:
eval('push @{$dirstruct{mydir}'.$dir.'}, $file');
Cheers,
Philip