use strict;
my $str = '#EXTM3U
#EXTINF:419,Alice in Chains - Rotten Apple
http://192.168.101.22:80/movies/9975.mkv
#EXTINF:260,Alice in Chains - Nutshell
http://192.168.101.22:80/movies/1254.mkv
#EXTINF:255,Alice in Chains - I Stay Away
http://192.168.101.22:80/movies/1254.mkv
#EXTINF:256,Alice in Chains - No Excuses
Alice in Chains_Jar of Flies_04_No Excuses.mp3
#EXTINF:157,Alice in Chains - Whale And Wasp
Alice in Chains_Jar of Flies_05_Whale And Wasp.mp3
#EXTINF:263,Alice in Chains - Don\'t Follow
Alice in Chains_Jar of Flies_06_Don\'t Follow.mp3
#EXTINF:245,Alice in Chains - Swing On This
Alice in Chains_Jar of Flies_07_Swing On This.mp3
';
my $regex = qr/(#EXTM3U\s+|#EXTINF:\d+,|(.*\.\w{3,4}).*\s+)/p;
my $subst = '';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html