in reply to multi line matching problem

What else are you doing to $text as your code, $text =~ s/\n\s*/ /g; deletes space chars preceeded by newlines, which looking at your test case seems to do what you want (in this case):
my $this = '<thing> condition condition randomness other junk </thing>'; print "before: $this\n\n"; $this =~ s/\n\s*/ /g; print "after: $this\n"; __END__ before: <thing> condition condition randomness other junk </thing> after: <thing> condition condition randomness other junk </thing>
One thing though is that \n is in the set of \s characters so $text=~s/\s+/ /g; should suffice.

-enlil