use strict;
my $str = 'Metalocalypse s03e01.avi
Metalocalypse s03e01.srt
Metalocalypse s03e02.avi
Metalocalypse s03e02.srt
Metalocalypse s03e03.avi
Metalocalypse s03e03.srt
Metalocalypse S03E04.avi
Metalocalypse s03e04.srt
Metalocalypse s03e05.avi
Metalocalypse s03e05.srt
Metalocalypse s03e06.avi
Metalocalypse s03e06.srt
Metalocalypse s03e07.avi
Metalocalypse s03e07.srt
Metalocalypse s03e08.avi
Metalocalypse s03e09.avi
Metalocalypse s03e09.srt
metalocalypse s03e10.avi
Metalocalypse s03e10.srt';
my $regex = qr/^[M|m]etalocalypse\ [s|S](\d\d)[e|E](\d\d)/mp;
my $subst = 'Metalocalypse.S\\1E\\2.XviD';
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