in reply to Hash pointing to multiple items
If in fact, your set for song1, song2, song3 are always mutually exclusive, then it might make sense to reverse the data structure to:my %hash = ( artistsong1 => { 1 => 1, 3 => 1, 5 => 1 }, artistsong2 => { 2 => 1, 4 => 1 } ); # to find for ArtistSong1, does 1 exist? if($hash{artistsong1}->{1}) { print "yes, 1 does exist for artistsong1!\n"; }
Or of course you could also make hashes of hashes of hashes like $hash{$artist}->{$song}->{1}) && print "yes, for $artist, $song, there's 1!\n";my %hash = ( 1 => artistsong1, 3 => artistsong1, 5 => artistsong1, 2 => artistsong2, 4 => artistsong2, 6 => artistsong3, 7 => artistsong3 ); # to find where 1 is? my $artistsong = $hash{1};
|
|---|