in reply to Using Perl Regex to find & replace large chunks in code
s% ;\s+This\s+code\s+does\s+something\s+fancy\s+ enable\s+fancy_command\s+ wait\s+\(fancy\s+=\s+true\)\s+or\s+for\s+\$max_time\s+ if\s+\$\$error\s+=\s+\$time\s+out\s+ write\s+"Oh\s+crap,\s+the\s+fancy\s+thing\s+didn't\s+work!"\s+ deal\s+with\s+not\s+working\s+ else\s+ do\s+fancy_command\s+ write\s+"fancy\s+command\s+done!"\s+ endif\s+%TESTING %six
which can be used as follows:
perl -i~ -0777p sub.pl *.cstol
-0777 causes the whole file to loaded into $_.
Update: Oops, that command is the same as you gave. I've just tested it and it works. Perhaps you didn't have a newline after the last endif?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Perl Regex to find & replace large chunks in code
by jedikaiti (Hermit) on Mar 11, 2013 at 21:55 UTC |