diarmuid has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm writing a simple mp3 cataloging program in perl and I am having some problem creating a hohoa. I have a list of mp3 which I want to store the mp3 tags
foreach my $mp3_file (@cdrom_mp3s) { chomp $mp3_file; my $mp3 = MP3::Tag->new($mp3_file); $mp3->getTags; if (exists $mp3->{ID3v1}) { my $id3v1 = $mp3->{ID3v1}; #print STDOUT $id3v1->artist," : ", $id3v1->song,"\n"; my $track_song = $id3v1->track."-".$id3v1->song; $artist_mp3{$id3v1->artist}{$id3v1->album}++; } }
As it is I end up with the number of tracks in each album (artist_mp3{$id3v1->artist}{$id3v1->album})

However how do I modify this so that the above variable contains an array of all the songs eg

push (@$artist_mp3{$id3v1->artist}{$id3v1->album}, id3v1->song);
except a working version ;-)

Diarmuid

Edit by tye

Replies are listed 'Best First'.
Re: constructing hohoa
by davorg (Chancellor) on Sep 26, 2001 at 20:18 UTC

    You're very close. Just need braces to tell Perl where the reference begins and ends.

    push (@{$artist_mp3{$id3v1->artist}{$id3v1->album}}, id3v1->song);
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

Re: constructing hohoa
by diarmuid (Beadle) on Sep 26, 2001 at 20:14 UTC
    sorry about the screwed up formatting. Dont know what happened. Opera put something into the text as I was previewing it.