in reply to Negative look ahead

So - so far all of the other responses have assumed you can read a line at a time. Sometimes you can't. Well - here is one possible option that will let you do what you want (assuming I know what you want) on a single string.
my $str = "<html> <title>Hi</title> <body> Some other lines of stuff </body> </html> "; $str =~ s{ ^(.+)$ (??{ lc(substr $^N, 0, 7) eq "<title>" ? '(?!)' : '(?=)' }) }{<para>$1</para>}xgm; print $str; # prints <para><html></para> <title>Hi</title> <para><body></para> <para>Some other lines</para> <para>of stuff</para> <para></body></para> <para></html></para>

This uses the delayed regex feature that lets you put a regex in a later point. It takes whatever is in $^N (the last match) and sees if begins with <title>. If it begins with title we put in '(?!)' which is a negative look ahead that will always fail - otherwise we put in '(?=)' which is a positive look ahead that will always succeed.

Unfortunately we have to do the testing to see if each line begins with title with with string methods rather than a nested regex. If we used a regex inside the (??{}) we would confuse the regex engine and in many (if not all) cases cause a segfault. But string methods often work just fine.

my @a=qw(random brilliant braindead); print $a[rand(@a)];