#!/usr/bin/perl use strict; use warnings; use XML::Twig; print "This will calculate the total amount and To no of transactions \n"; my $totalamt = 0; my $cnt = 0; my $twig = XML::Twig->new( twig_handlers => { b => \&b_handler, payment_amount => \&amt_handler }); $twig->parse(do {local $/; }); print "The total amount found is $totalamt \n"; print "Total Transactions are $cnt \n"; $twig->purge(); sub b_handler { my ($t, $b_elem) = @_; $cnt++; $b_elem->delete(); } sub amt_handler { my ($t, $amt_elem) = @_; $totalamt += int($amt_elem->text()); } __DATA__ 68789790390909090489 MTRIN10909890896 700000 9033753053985392INR 938573895735154 1222706 9284723472047222INR RP JLLKL7687 1437865.95