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;

In reply to comparing two lists by ashaman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.