in reply to Re^6: perl script to search and replace comment in .aspx file
in thread perl script to search and replace comment in .aspx file
I didn't know about YAPE. Nifty module. Thanks Corion, always seem to stumble into something new from reading your posts =)
hector89, be sure to take some time to understand the code in all these replies it will help you write your own solution next time!
This should do what you want:
use strict; open my $input_fh, '<', 'your_input.aspx'; my $delim = $/; $/ = ''; my $file = <$input_fh>; $/ = $delim; close $input_fh; $file =~ s/(<%--)?\s*<script(.*?)>/($1 ? '' : "\n<%-- ") . "<script$2> +"/ige; $file =~ s=</script>\s*(-->)?='</script>' . ($1 ? '' : " -->\n")=ige; print $file; open my $output_fh, '>', 'your_output.aspx'; print $output_fh $file; close $output_fh;
Forgot to turn off greedy matching for the script attributes group in my first post, which might be why you were having issues with input that's all on one line.
Strange things are afoot at the Circle-K.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: perl script to search and replace comment in .aspx file
by hector89 (Novice) on Jun 08, 2012 at 13:59 UTC | |
by temporal (Pilgrim) on Jun 08, 2012 at 14:21 UTC | |
by hector89 (Novice) on Jun 08, 2012 at 14:27 UTC | |
by hector89 (Novice) on Jun 08, 2012 at 14:37 UTC |