in reply to perl script to search and replace comment in .aspx file
You could slurp the file and do a greedy regex substitution over it.
use strict; my $delim = $/; $/ = ''; my $file = <DATA>; $/ = $delim; $file =~ s/(<%--)?\s*<script(.*)>/($1 ? '' : '<%-- ') . "<script$2>"/i +ge; $file =~ s=</script>\s*(-->)?='</script>' . ($1 ? '' : " -->\n")=ige; print $file; __DATA__ <script type="java/js"> foobie bletch </script> <%-- <script> zelgo mer </script> -->
Strange things are afoot at the Circle-K.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: perl script to search and replace comment in .aspx file
by hector89 (Novice) on Jun 08, 2012 at 05:54 UTC | |
by Corion (Patriarch) on Jun 08, 2012 at 06:00 UTC | |
by hector89 (Novice) on Jun 08, 2012 at 06:15 UTC | |
by Corion (Patriarch) on Jun 08, 2012 at 06:39 UTC | |
by stevieb (Canon) on Jun 08, 2012 at 07:24 UTC | |
by hector89 (Novice) on Jun 08, 2012 at 09:25 UTC | |
| |
by hector89 (Novice) on Jun 08, 2012 at 11:24 UTC | |
|
In Section
Seekers of Perl Wisdom