#!/usr/bin/perl -w use strict; use XML::Twig; # you will actually get the list from a file my %to_remove= map { $_ => 1 } ( "1742-7061"); XML::Twig->new( twig_roots => { journal => \&journal }, pretty_print => 'indented', ) ->parse( \*DATA) # replace by parsefile( "file.xml") ->flush; sub journal { my( $t, $journal)= @_; # this works if the ISSN is a child of journal, # otherwise it might be a little more tricky. if( $to_remove{$journal->field( 'ISSN')}) { $journal->delete } else { $t->flush; } # ouput and cleanup memory } __DATA__ Acta Biomaterialia 1742-7061 1 01-01-1974 1 200 Acta Biomaterialia 1743-7061 1 01-01-1974 1 200