in reply to Replacing duplicate string
Output:use strict; use warnings; while (<DATA>) { if (/^Class voip/ .. /^\s*$/) { s/priority/bandwidth/; } print; } __DATA__ Class control priority 5 Class voip priority 30 Class video priority 40 Class control priority 10 Class voip priority 25 Class video priority 45
Class control priority 5 Class voip bandwidth 30 Class video bandwidth 40 Class control priority 10 Class voip bandwidth 25 Class video bandwidth 45
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|