I want to save each file's data as an array, then add that array to the the hash. At the end of all this, for each file in the dupes, I'll get the display the array of its data, something likemy %fileinfo = (); # name -> (array-of-path+size+etc) my $href = \%fileinfo; my %dupes = (); # name->count my $dref = \%dupes; #------------------------ foreach # for each file, recursing through directory tree { # here $_ is each file name if( exists %$href->{ $_ } ) # if filename seen already { %$dref->{ $_ } = 1; # then record in %dupes } @filedata = ( $fpath, $fsize, $fdate ); # but using real data # this is where I'm lost -- don't know how to "savedata" @savedata = %$href->{ $_ }; # get data data saved for filename push @savedata, @filedata; # add new data to saved data %$href->{ $_ } = @savedata; # put new data back in the hash }
Please tell me how to do the step of adding the new data, the one I've dummied as:myfile.mp3 c:\dir1\dir2; date=12/3/45; size=12345 c:\dir3\dir4; date=1/01/01; size=54321
(which doesn't work as I'd hoped :-( where I'd thought the @savedata would have lots of little @filedata arrays inside it ... thanks for any advice (and hints on how to unpick the "@savedata" would be great too)@savedata = %$href->{ $_ }; push @savedata, @filedata; %$href->{ $_ } = @savedata;
In reply to data structure advice please by anadem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |