my %all_mp3s = (); opendir(MUSIC_DIR, $mp3_file_path) || die "$mp3_file_path coud not be opened: $!"; while( defined ( my $artist_dir = readdir MUSIC_DIR) ) { next if $artist_dir =~ /^\./; next if !(-d "$mp3_file_path/$artist_dir"); print "scanning dir $mp3_file_path/$artist_dir\n"; opendir(ARTIST_DIR, "$mp3_file_path/$artist_dir") || die "$mp3_file_path/$artist_dir coud not be opened: $!"; while( defined ( my $album_dir = readdir ARTIST_DIR) ) { next if $album_dir =~ /^\.\.?$/; $all_mp3s{"$artist_dir/$album_dir"} = 0; } }