use strict; use warnings; use XML::Twig; #open(FH, "conv.xml"); my $file="C:/conv.xml"; my $tmp; $tmp = XML::Twig->new(); $tmp->parsefile($file); my $root = $tmp->root; my $hex_value; my $entity_value; my $real_value; #while (){ open(FH, ">records.txt"); foreach my $record ($root->children('record')){ if ($record->first_child_text('hex_value') eq '') { $hex_value=''; }else{ $hex_value = $record->first_child_text('hex_value'); $hex_value=~s/^\s*//g; } if ($record->first_child_text('entity_value') eq '') { $entity_value=''; }else{ $entity_value = $record->first_child_text('entity_value'); $entity_value=~s/\s*$//g; } if ($record->first_child_text('real_value') eq '') { $real_value=$entity_value.";"; } #print "$real_value\n"; #print FH "Hexadecimal Value \t Entity Value \t Real_value"; print FH "\'$real_value\' => \'$hex_value\',\n"; }