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"; > 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