Regarding the question: what does
{$playlist{$_} = 1 do: In a
while(<PLAYLIST>) loop like yours,
$_ contains the current record, so the statement you are wondering about sets a value of 1 in the hash for the current record.
One reason I can see why this would fail is if you have trailing spaces in your input file, because e.g.
'cool_song.mp3 ' is not the same as
'cool_song.mp3', which is what you will get from readdir. So this is how I would code the loop to avoid this:
while (<PLAYLIST>) {
s/#.*//g; #delete comments
s/(^\s*|\s*$)//g; #delete leading and trailing spaces
$playlist{$_} = 1 if /\.mp3$/;
}
To tell exactly what failed, of course, I would have to see also the input file.
Don't be discouraged, be cautious - we all deleted precious files some time or other.
pike