#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; { my $xml = <<'__XML__'; STUFF T BLAH __XML__ my $t = XML::Twig->new( pretty_print => 'indented', twig_handlers => { '_all_' => sub { my ( $t, $e ) = @_; my $tag = $e->tag; if ( $tag =~ s/\.//g ) { $e->set_tag($tag); } $t->flush; ## does the printing return; }, }, ); $t->xparse($xml); $t->purge; undef $t; } __END__ STUFF T BLAH