#!C:/Perl/bin/perl
format STDOUT_TOP =
-----------------------------------------------------------------------
@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"MERA BAZZAR - TERA BAZZAR"
-----------------------------------------------------------------------
@<<<<< @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<< @<<<<<<<< @>>>>>>> @>>>> @#
CODE,DATE,DESCRIPTION,PRICE,QUANTITY,AMOUNT,Page,$%
-----------------------------------------------------------------------
.
format STDOUT =
@<<<<< @>>>>>>>>> @<<<<<<<<<<<<<<<<<<< @####.## $ @######### @####.## $
$CODE,$DATE,$DESCRIPTION,$PRICE,$QUANTITY,$AMOUNT
.
format STDOUT_TOTAL =
-----------------------------------------------------------------------
TOTAL = @###.## $
$TOTAL
.
open(INP, "item.dat") || die "Can't read file - $!\n";
while (<INP>)
{
($CODE,$DATE,$DESCRIPTION,$PRICE,$QUANTITY) = split(/\t/);
$AMOUNT=$PRICE * $QUANTITY;
write;
$TOTAL += $AMOUNT;
}
close(INP);
$~ = "STDOUT_TOTAL";
write;
# Footer
$^L = '-' x 71 . "\n Copyright, 2012, MERA BAZZAR - TERA BAZZAR \n" . '-' x 71 . "\n";
print ("$^L");
The ITEM.DAT file should contail the following data of columns separated by a TAB :
SOA01 01-01-2012 LUX 01.35 03
SOA02 03-01-2012 LYRIL 01.15 06
SOA03 02-02-2012 DOVE 01.20 09
SOA04 04-02-2012 HAMMAM 01.10 03
SOA05 12-02-2012 NIRMA 01.36 06
SOA06 03-03-2012 RIN 01.50 09
SOA07 10-03-2012 SURF 01.85 03
SOA08 04-04-2012 DETOL 01.90 06