use stric; use warnings; my @files = qw( XY201308.TXT TW201308.TXT KG201308.TXT MM201308.TXT ); foreach my $file (@files) { # triyng to lower case the to letters and replace the digits with yy $file=~s/(\w{2})(\d+)/$1\lc($1),$2\lc(yy)/e; print "\n $file \n"; }