open DR, ">ddailyreport.prn" or die "Cant open file"; format DATA = @<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<< @##### @############### Rs@#####.## ~ $consname, $subdvn, $chequeno, $receiptno, $amount . format TOTAL = ------------------------------------------------------------------------------------------- Rs@#####.## $total . format TOP = @|||||||||||||||||||||||||||||||||||| Pg @< "Daily Deposit Works Report", $% Consumer name Subdivision Cheque no. Receipt no. Amount -------------- -------------- ------------- -------------- ------- . sub dotize { my($width, $string) = @_; if (length($string) > $width) { return(substr($string, 0, $width - 3) . "..."); } else { return($string); } } $~ = "TOP"; write(DR); open(FILE, "; close(FILE); $total = 0; foreach (@lines) { chop(); ($consname, $subdvn, $chequeno, $receiptno, $amount) = (split(/!/)); $consname = "" if !defined($consname); $subdvn = "" if !defined($subdvn); $chequeno = 0 if !defined($chequeno); $receiptno = 0 if !defined($receiptno); $amount= 0 if !defined($amount); $~ = "DATA"; write(DR); $total += $amount; } $~ = "TOTAL"; write(DR); close(DR);