open(BASE, "C:/POS/POSA.xml"); open(IN, "C:/POS/Macro/awb.txt"); open(OUT, ">POSA_new.xml"); %map = (); while () { chomp $_; @items = split(/\,/, $_); $map{$items[0]} = $items[2]; } close IN; $cur_awb = "0"; $cur_val = $map{$items[0]} = $items[2]; while () { chomp $_; if ($_ =~ m/\(\d*)\<\/KEY_BOL_REF\>/) { $cur_awb = $1; print OUT $_ . "\n"; } elsif ($_ =~ m/\/) { print OUT "\t" .$cur_val. "\n"; } elsif ($_ =~ m/\/) { print OUT "\tUSD\n"; } else { print OUT $_ . "\n"; } }