# for offline conversion, set this to 1 $offline = 0; undef $/; open( FILE, "< $filename" ) or die "Can't open $filename : $!\n"; $HTML = ; close FILE; # Note that you can use \2 (or $2) in the new title part # to reference the old title. $HTML =~ s!(.*?)(.*?)(.*)!... new title here ...!ims; ($Left, $Title, $Right) = ($1,$2,$3); # Here, $Left contains everything left of the page title # $Right contains everything right of the page title # and $Title contains the page title # here you could do some more magic to the page title # before assigning it back to $HTML ... if ($offline) { rename $filename, "$filename.backup"; open( FILE, "> $filename" ) or die "Can't create $filename : $!\n"; print FILE $HTML; close FILE; } else { print FILE; };