Skip to content

Instantly share code, notes, and snippets.

@mshock
Created June 7, 2012 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mshock/2890951 to your computer and use it in GitHub Desktop.
Save mshock/2890951 to your computer and use it in GitHub Desktop.
toggle commented script tags in .aspx
use strict;
my $delim = $/;
undef $/;
my $file = <DATA>;
$/ = $delim;
$file =~ s/(<%--)?\s*<script(.*?)>/($1 ? '' : "\n<%-- ") . "<script$2>"/ige;
$file =~ s=</script>\s*(-->)?='</script>' . ($1 ? '' : " -->\n")=ige;
print $file;
__DATA__
<script type="java/js">
foobie bletch
</script>
<%-- <script>
zelgo mer
</script> -->
@mshock
Copy link
Author

mshock commented Jun 7, 2012

Slurp an aspx file and comment uncommented script tags and uncomment commented script tags. Probably could fit it all in one regex...

@mshock
Copy link
Author

mshock commented Jun 7, 2012

Note - it looks like github's perl markup isn't smart enough to recognize alternative regex delimiters. Or __DATA__ tokens: https://gist.github.com/2891256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment