i'm trying to make a script that will go through my winamp playlist and through my mp3 directory. it'll then compare the two lists, and if there are any files in the directory that aren't in the playlist, they'll be deleted. hehe, trying to clean up the stuff i don't want anymore. but unfortunately it isn't doing that, and hence i find myself here, begging knowledge. i think the problem is in the if statement, but that's about all i can figure out after staring at it for several hours and asking my programmer friend for help as well.
use strict;
open(PLAYLIST, "<playlist.m3u");
opendir(FILES, 'd:\my files');
my @playlist = ();
my @filelist = grep {/\.mp3$/} readdir FILES;
my $song;
while(<PLAYLIST>) {
if(not(/#/)) {push(@playlist, $_)}
}
foreach $song(@filelist) {
if(grep($song, @playlist) == 0) {
unlink($song)
}
}
closedir FILES;
close PLAYLIST;