#!/usr/bin/perl use warnings; use strict; my @t; my $i; while (<>) { @t = split /([<>])/, $_; for ($i = 0; $i <= $#t; $i++) { next if $i % 4 != 0; $t[$i] =~ s/_/ /g; } print join "", @t; }