Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with formatting a report

Status
Not open for further replies.

MinniePerl

Technical User
Apr 19, 2001
7
0
0
US
I'm bringing data in from a:\, substituting x for s and counting the number of substitutions. Then I need to print the results out in a report. I can't get the Header(format REPORT_TOP=) to print out at all. I'm not sure what I'm missing. Also, the body prints out mostly zeros. Anybody see my blunders? Thx.



open (OLDFILE, &quot;<a:\\program1.txt&quot;); #retrieve data
@databack=<OLDFILE>; #assigns to array
close(OLDFILE); #closes


foreach (@databack)
{ #creates foreach loop, so each array is split
#and subs are made, subs counted

$count=s/s/x/ig; #saves number of subs to $count
$total=$total + $count; #adds new sub. number to each loop
s/s/x/ig; #subs all s with x
($item, $itemprice, $itemnumber, $totalprice)=split(/, /,); #splits data

}
print &quot;$total &quot;.&quot;characters have been substituted.\n\n&quot;;

print @databack;


format REPORT_TOP=
========================================================== @<
ITEM PRICE QUANTITY TOTAL PRICE
==========================================================
$%
.


format=
@<<<<<<< $@####.## @##### @####.##
$item, $itemprice, $itemnumber, $totalprice
.

open (REPORT, &quot;<a:\\program1.txt&quot;);
@lines=<REPORT>;
close (REPORT);

foreach (@lines) {
chop;
($item, $itemprice, $itemnumber, $totalprice)=(split(/!/));
$item=&quot; &quot; if !defined($item);
$itemprice=0 if !defined($itemprice);
$itemnumber=0 if !defined($itemnumber);
$totalprice=0 if !defined($totalprice);
write();
}






<STDIN>;
 
I got the body to come out right. I was using the wrong character in (split(/!/));
I still can't get the header to print out.
Minnie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top