in reply to Re^2: perl script to search and replace comment in .aspx file
in thread perl script to search and replace comment in .aspx file
Any time you're parsing text, a lot depends on how much the patterns you're trying to match may vary. If your tags may or may not span multiple lines, or may have their attributes in different orders, or other variations, parsing them can be very complicated. (Which is why it's often a good idea to use a module if there is one.) If you know your open and close tags will always be on the same line, and never more than one pair on the same line, it could be pretty simple:
perl -p -i -e 's|(<script.+/script>)|<%-- $1 -->| unless s|<%--(\s*<sc +ript.+/script>\s*)-->|$1|' *.aspx
Aaron B.
Available for small or large Perl jobs; see my home node.
|
|---|