Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Using Perl Regex to find & replace large chunks in code

by ikegami (Pope)
on Mar 11, 2013 at 18:54 UTC ( #1022847=note: print w/ replies, xml ) Need Help??


in reply to Using Perl Regex to find & replace large chunks in code

Actually, you should have gotten

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?


Comment on Re: Using Perl Regex to find & replace large chunks in code
Select or Download Code
Re^2: Using Perl Regex to find & replace large chunks in code
by jedikaiti (Friar) on Mar 11, 2013 at 21:55 UTC
    I will make sure I have that newline, thanks!
    Kaiti
    Swiss Army Nerd

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-10-22 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls