in reply to it's been awhile . . .

Oy vey, how painful.

I can't see why the code wouldn't do what it says on the can. My guess is that somewhere in there, perhaps at /#/ there's a mismatch between your playlist and the test criteria you apply to it, and @playlist ends up with the wrong stuff in it. To find out what's going wrong, I'd take the first half of your code and do
open(PLAYLIST, "<playlist.m3u"); opendir(FILES, 'd:\my files'); my @playlist = (); open TEMP ">playlist.txt"; while(<PLAYLIST>) { if(not(/#/)) {print TEMP "$_\n"} }
Then examine playlist.txt at your leisure and see whether it is what you'd expect it to be. Of course, before you run this... make sure you don't have a treasured file called playlist.txt that will get overwritten... that would be just too cruelly ironic.

Please do post again and say how you get on and ask any other questions that occur to you. Perl is your friend, really, despite appearances.

§ George Sherston