in reply to Re^2: splice an array
in thread splice an array

I second toolics suggestion of using alternate delimiters. These are all equivalent
perl -MO=Deparse -e " s///g " perl -MO=Deparse -e " s\\\g " perl -MO=Deparse -e " s[][]g " perl -MO=Deparse -e " s()()g " perl -MO=Deparse -e " s{}{}g " perl -MO=Deparse -e " s!!!g " perl -MO=Deparse -e " s###g " perl -MO=Deparse -e " s vvvg " perl -MO=Deparse -e " s ___g " perl -MO=Deparse -e " s {}//g " perl -MO=Deparse -e " s {}\\g " perl -MO=Deparse -e " s {}vvg " perl -MO=Deparse -e " s {}()g " perl -MO=Deparse -e " s {}[]g " perl -MO=Deparse -e " s {}<>g " perl -MO=Deparse -e " s<><>g "
They all output
s///g; -e syntax OK
But don't get fooled by the balancing act, it doesn't work for other chars like « and »
$ perl -MO=Deparse -e " s«»«»g " Substitution replacement not terminated at -e line 1. $ perl -MO=Deparse -e " s«««g " s///g; -e syntax OK
s'''g is special in that it doesn't interpolate

Replies are listed 'Best First'.
Re^4: splice an array (alternate delimiters)
by dbs (Sexton) on May 04, 2011 at 17:31 UTC
    I am not getting this solution guys. I appreciate the help, but had a hard time understanding Rolfs code and played with it for a while with little success. With that being said, my temp solution, I understand is the way I would like to follow.
    while ( defined( $_ = <$Rlog> )) { s/^Alert Level\s0*(?:[3-9]|\d{2,})/DEREK_SMITH\n$&/s; } continue { print $_; } ###-- this works, but only half way. __OUT__ ========================================== Log Entry 13: 20 Feb 2011 08:33:42 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60D1E60200E0 FFFF027000120300 ========================================== Log Entry 12: 20 Feb 2011 07:14:27 DEREK_SMITH Alert Level 4: TEST ALERT!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60BF530200D0 FFFF027000120300 ========================================== Log Entry 11: 13 Feb 2011 07:24:32 DEREK_SMITH Alert Level 5: TEST ALERT!!!!!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D5787300200C0 FFFF027000120300 __DATA__NEEDED__ ========================================== Log Entry 13: 20 Feb 2011 08:33:42 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60D1E60200E0 FFFF027000120300 ========================================== Log Entry 12: 20 Feb 2011 07:14:27 DEREK Alert Level 4: TEST ALERT!!!!!!!!!!!!!!!! SMITH Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60BF530200D0 FFFF027000120300 ========================================== Log Entry 11: 13 Feb 2011 07:24:32 DEREK_ Alert Level 5: TEST ALERT!!!!!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 SMITH Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D5787300200C0 FFFF027000120300
    either SMITH after 'Keyword' or after 'Alert' either one is fine.
Re^4: splice an array (alternate delimiters)
by dbs (Sexton) on May 04, 2011 at 17:48 UTC
    I got this working better that halfway, and its usable. Any other help is welcome!
    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 ==========================================