Do this:
Find:
=====
print "$ThisHTML";
Add ABOVE:
==========
$ThisHTML =~ s//$ChatHTML/g;
$ThisHTML =~ s//$invitehtml/;
Find (again):
=============
print "$ThisHTML";
Add ABOVE:
==========
$ThisHTML =~ s//$ChatHTML/g;
$ThisHTML =~ s//$invitehtml/;
Find (for the last time):
=========================
print "$ThisHTML"; exit;
Add ABOVE:
==========
$ThisHTML =~ s//$ChatHTML/g;
$ThisHTML =~ s//$invitehtml/;
Hope that works.