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.
In reply to Re^7: perl script to search and replace comment in .aspx file
by temporal
in thread perl script to search and replace comment in .aspx file
by hector89
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |