use strict; open(PLAYLIST, "test.txt"); my %playlist; my @filelist = grep {/\.mp3$/} readdir FILES; my $song; while() { chomp; if(not(/#/)) {$playlist{$_} = 1} } foreach $song(@filelist) { if(!exists $playlist{$song}) { print TEST $dir . "\\" . $song . "\n" } } closedir FILES; close PLAYLIST;