I might have simplified this too much, but: $html = ' '; $html =~ s//GONE/s; print $html; what I want to produce is leave the first comment tag, while replacing the second with GONE (and yes I do need to grab the xxxx text) the 'xxxx' in both tags may be anything, and may span several lines I may not always be looking for 'DOS', this was just an example. my problem is that it chews up the first one, starting with from DOS's tag..