in reply to comparing two lists
this works for me:
use strict; open(PLAYLIST, "<playlist.m3u"); opendir(FILES, 'd:\my files'); my %playlist ; my @filelist = grep {/\.mp3$/} readdir FILES; my $song; while(<PLAYLIST>) { chomp; if(not(/#/)) {$playlist{$_} = 1} } foreach $song(@filelist) { if(!exists $playlist{$song}) { unlink($song) } } closedir FILES; close PLAYLIST;
hashes are sweet. (and notice the chomp)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: comparing two lists
by ashaman (Sexton) on Jun 24, 2001 at 08:28 UTC | |
by chipmunk (Parson) on Jun 24, 2001 at 18:16 UTC |