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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Print Formats 1

Status
Not open for further replies.

tbohon

Programmer
Joined
Apr 20, 2000
Messages
293
Location
US
OK - I give up. I've spent the past hour trying to figure out why I don't get values printed for $nr, $price and $totamt.

Here's the code:
Code:
#!/usr/bin/perl

$totnritems = 0;
$mdsetotal = 0;

$~ = STDOUT_TOP;

$~ = HEADER_LINE;
write;

$~ = DETAIL_LINE;


format STDOUT_TOP =
COMPANY NAME, INC.
I N V O I C E


.

format HEADER_LINE =
-------------------------------------------------------
Item #     Description           Qty    Price     Total
-------------------------------------------------------
.

format DETAIL_LINE =
@<<<<<<<<  @<<<<<<<<<<<<<<<<<<<< @##   ###.##   ####.##
$itemnr, $descr, $nr, $price, $totamt
.

format TOTAL =
-------------------------------------------------------
                         Totals @###           @####.##
$totnritems, $mdsetotal
.

format ADDLCHGS = 
                                               @####.##
.


$line = "AUSMIX25|Australia Mix (25)|1|1.00";





	($itemnr, $descr, $nr, $price) = split(/\|/, $line);
	$totamt = $nr * $price;
	$nr = sprintf("%03d",$nr);
	$price = sprintf("%03.%02", $price);
	$totamt = sprintf("%04.%02", $totamt);
	

	
	write;

We all know that it's something really, really obvious but I'll be darned if I see it.

Comments/slings and/or arrows/suggestions accepted gracefully.

Tnx.

Tom

"My mind is like a steel whatchamacallit ...
 
don't you need an '@' symbol before each field?

Code:
@<<<<<<<<  @<<<<<<<<<<<<<<<<<<<< @##   [COLOR=#ff0000]@[/color]###.##   [COLOR=#ff0000]@[/color]####.##
 
<SIGH>

Yes, I do ...

TOLD you it was something (stupidly) simple.

Excuse me, I'm going to go take my medication now ... :-)

Thanks, Kevin ...

(a really embarassed) Tom

"My mind is like a steel whatchamacallit ...
 
LOL...no problem. Three eyes are better than two, assuming you have two.... ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top