in reply to extract date from filename - need help

Your problem is that your regex effectively boils down to /\d{12}/ ignoring the substitution and variable capture, so it will only match a 12 digit number.
You actually need to match the _ and : characters.
What you want would be something like.
my $file = "textfile.020701_00:08"; my $time = substr($file, 9,12); $time =~ s/(\d{6})_(\d{2}):(\d{2})/"$1$2$3.monday"/; print "TIME: $time";