my $text;if (open(IN, "<$fname")){ local $/ = undef; $text = <IN>; close(IN); if ($text =~ m|<title>(\s*[^<]+)</title>|){ my $hold = $1; $text =~ s|<title>\s*</title>|<title>$hold</title>|; } if (open(OUT, ">$fname")){ print OUT $text; close(OUT); }}