use strict; use XML::Simple; my $xs = XML::Simple->new(KeepRoot=>1); my $data; { local $/; $data = ; } my $inStruct = $xs->XMLin($data); my $outStruct; foreach my $tag (@{$inStruct->{Root}->{'dc:subject'}}) { my @matches = $tag->{content} =~ /(\d+th century)/g; foreach my $match (@matches) { my %item = %$tag; $item{content} = $match; push(@{$outStruct->{Root}->{'dc:subject'}}, \%item); } } my $resultXML = $xs->XMLout($outStruct); print $resultXML; __DATA__ 18th century 17th century 18th century 14th century 18th century 12th century 18th century 11th century 18th century 10th century 18th century 12th century 18th century 12th century 12th century 12th century 12th century