in reply to can't get $& to remove value in a substitution

Be careful with greedy matches. You're doing
while ($content =~ m/(<textarea.*textarea>)/sg) {
If your $content contains more than one textarea, this will match from the beginning of the first textarea to the end of the last one. That makes the /g fairly useless.

You probably want:

while ($content =~ m/(<textarea.*?textarea>)/sg) {
Notice the *? non-greedy qualifier; that makes sure the first textarea> is matched.

Of course, this might not be the source of the problem you're asking about, but it is one possible problem with your code.
--
Mike

Replies are listed 'Best First'.
Re: Greed is going to get you, was Re: can't get $& to remove value in a substitution
by zusuki-san (Initiate) on Oct 24, 2002 at 13:54 UTC
    thanks for pointing that out...i didn't use the non-greedy qualifier because i know that i will only encounter one "textarea" in my file.
      Now you've confused me :) (Don't worry, it's easy to confuse me)

      Why use while(//g) if there's only ever going to be one match?
      --
      Mike

        erm, you're right...i meant to use non-greedy matching, oversight on my part :)
        thanks for pointing it out