#!usr/local/bin/perl $filename = "input.txt"; open (FILE,"<$filename"); @fileinput=; close(FILE); foreach $line(@fileinput) { # Capitalieze first letter of each word found after marker AU: and add written by: $line=~s/AU:\s\b(\w+)\s\b(\w+)|AU:\s\b(\w+.)|AU: ([\s\w\s\b]+)/AU: Written by: \u$1 \u$2\u$3/g; #extract numeric id in () if($line=~/\(\d{6}\)/) {$line=~s/$&//; print "$&\n"; }