1. The substitution operation is removing all tags and their content from the string. A simpler way to write the pattern is to use the ? operator to get a minimal match: $line =~ s/<.*?>//g

  2. One possible solution:
         open(FILE, $ARGV[0]) or die "$ARGV[0]";
         $line = join('', <FILE>);
         $line =~ s/^(<(h[1-3])>.*?<\/\2>)/<center>\1<\/center>/smg;
         print $line;
         

  3. backup.pl

  4. count_bytes.pl