foreach ( @lines ) { s/#(?=<-\(0N<-\(s3T)/*/g; push(@newlines,$_); } #### /(?<=preceding_part)target_part/