in reply to Re^2: regex: Need help substituting
in thread regex: Need help substituting

I'm just curious as to why you're using the many if statements.
I suppose the following should work:

$data=~ s{<rstate>[^<\n]+</rstate>}{<rstate>$new_text</rstate>}g
Note the use of the 'g' modifier.
If you want to learn more about regular expressions in general, then Friedl's book is a must. It's one the most well-written books I've ever read on any subject and I highly recommend it.

Replies are listed 'Best First'.
Re^4: regex: Need help substituting
by the_perl (Initiate) on Apr 09, 2012 at 14:36 UTC

    Hi, I don't anylonger. I approached the problem the wrong way, and all I have now is the three lines above to substitute <rstate> at different specific places in the file. Totally agree on the book! I ordered it a while ago but haven't had the time to read it. I'm going to now since I will have good use for regexp in my present work. Thanks

      Enjoy it. It's such a great read! It improved my regexes by orders of magnitude...