in reply to Weird situation...

Let me try this again... the code didn't show up properly!!!!

Hello brother monks... I have a series of lines throughout some generated output which come in the form of:


</a> <!-- rem_me --></li> <li>

I planned on replacing all instances of the middle line:

<!-- rem_me --></li>

with <ul>

One would think that in my situation this would be a simple case of: $html =~ s/<!-- rem_me --><\/li>/<ul>/sig;
But strangely this didn't work... A quick search with a hex editor shows nothing out of the ordinary... There are two 0A characters on either side of the line, which can only be attributed to the \n characters...

So what am I missing here?

Regards, Fib Jones

Replies are listed 'Best First'.
Re^2: Weird situation...
by ikegami (Patriarch) on Mar 19, 2008 at 23:32 UTC

    Works for me, as I would expect it to.

    my $html = do { local $/ = undef; <DATA> }; $html =~ s/<!-- rem_me --><\/li>/<ul>/sig; print($html); __DATA__ </a> <!-- rem_me --></li> <li>
    </a> <ul> <li>

    What's rem_me in reality?

      It (<!-- rem_me -->) was a marker for the generated output... not all instances of:

      </a> </li> <li>
      were in need of being changed... so this marker was created in the hope that the above replacement would pick it up... Why wouldn't it work on my end? There's about 5 different instances, and there's no way I can just hardcode this directly into the page as the output is dynamic.
        The file or $html doesn't contain what you think it does. Or it does work and there's an independent problem. Or you're not using the code you think you are using.