Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: perl script to search and replace comment in .aspx file

by temporal (Pilgrim)
on Jun 07, 2012 at 19:05 UTC ( #975017=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: perl script to search and replace comment in .aspx file
Download Code
Re^2: perl script to search and replace comment in .aspx file
by hector89 (Novice) on Jun 08, 2012 at 05:54 UTC

    this code not working temporal..:(..

      You might tell us how the code fails for you, and on what input, and what output you get.

        __DATA__ <script type="java/js"> foobie bletch </script> <%-- <script> zelgo mer </script> --> input is same as temporal used.but when i'm executing this code it's not able to make changes in file.i'm using .txt file

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://975017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-25 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls