> Have you considered using a hash of arrays instead? > > push @{$files{'.pl'}}, ':folder_one:byte.pl'; > push @{$files{'.pl'}}, ':folder_one:byte.pl'; > push @{$files{'.gif'}}, ':folder_one:some.gif'; > > etc. > > Ronald
actually yes, though with this syntax: $hash_of_file_extensions{".pl"} = [":folder_one:byte.pl", 1]; but that didnt help much, because i still could not maintain the insert order. it seems the only "nonmodular" way is by a push. i have given up with the tie::Hash module as i could not get it to maintain the order of the inner hash, the outher hash was no problem. so my current code (which is unfortuantely slow as it is a pretty large filesystem) looks something like this (i dont have it right here): $hash_of_file_extensions{$extension} = $level; # this is just to grab each extension only once, i dont actually use the level variable push(@somearray, $extension, $file); # then some time consuming stuff like this: foreach $key (sort(keys % hash_of_file_extensions)) { print "$hash_of_file_extensions\n"; for ($i = 0; $i <= $#somearray; i++) { if ($somearray[$i] eq $key) { print $somearray[$i+1] \n"; } } } any suggestions for improvemnt much appriciated. thanks allan Ronald J Kimball wrote: > > On Sun, Oct 28, 2001 at 01:24:35PM +0100, allan wrote: > > hi > > while traversing a filesystem i want to output a list of all files > > grouped by file extensions. > > this is no problem in itself but in the output i want the file names to > > appear in their correct sorted or nested order (which is in the order > > they entered the hash). > > considering the test script below i have a for loop that can do the > > order for me (but no filenames) and a while loop that can produce the > > filenames (but unordered). > > > $hash_of_file_extensions{".pl"}{1} = ":folder_one:byte.pl"; > > $hash_of_file_extensions{".pl"}{2} = ":folder_one:compare.pl"; > > $hash_of_file_extensions{".gif"}{3} = ":folder_one:some.gif"; > > $hash_of_file_extensions{".gif"}{4} = ":folder_one:folder_two:pic.gif"; > > $hash_of_file_extensions{".pl"}{5} = ":folder_one:folder_two:cool.pl"; > > $hash_of_file_extensions{".pl"}{6} = ":folder_one:folder_two:nested.pl"; > > $hash_of_file_extensions{".pl"}{7} = >":folder_one:folder_two:folder_three:hash.pl"; > > $hash_of_file_extensions{".gif"}{8} = >":folder_one:folder_two:folder_three:b_.gif"; > > $hash_of_file_extensions{".pl"}{9} = >":folder_one:folder_two:folder_three:last.pl"; > > $hash_of_file_extensions{".gif"}{10} = >":folder_one:folder_two:folder_three:last.gif"; > >