#!/usr/bin/perl print "This will calculate the total amount and To no of transactions \n"; my $totalamt = 0; while(){ chomp; if ($_ =~ /payment amount/i){ $cnt++; while($_=~m/\<(.+?)\>(.+?)\<\/\1\>/sig){ my $value=$2; $totalamt += $value; } print $_,"\n"; } } print "The total amount found is $totalamt \n"; print "Total Transactions are $cnt \n"; __DATA__ 68789790390909090489 MTRIN10909890896 700000 9033753053985392INR 938573895735154 1222706 9284723472047222INR RP JLLKL7687 1437865.95