my %clocks = ( '12:34:56.78' => 'Grub up!' ); $_ = 'Stuff here: Mon Feb 12 12:34:56.78 2005 More stuff here'; s/\w{3} \w{3} \d+ (\d+:\d+:\d+\.\d+) \d{4}/$clocks{$1}/; print; ## Will print "Stuff here: Grub up! More stuff here"