while ( defined( $_ = <$Rlog> )) { s/^Alert Level\s0*(?:[3-9]|\d{2,})/DEREK\n$&\nSMITH\n/s; } continue { print $_; } __OUT__ ========================================== Log Entry 11: 13 Feb 2011 07:24:32 DEREK Alert Level 5 SMITH : TEST ALERT!!!!!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D5787300200C0 FFFF027000120300 ==========================================