for my $xml_file ( @xml_files ) { eval { # do something with $xml_file }; if ( $@ ) { print $logfile "file: $xml_file has errors ( $@ )\n"; } }