Hello,
Im trying to run a format twice. The problem is that unless I use STDOUT as the format name it fails, and if i use it twice it redefines it.
#!/usr/bin/perl -w
use strict;
use warnings;
print "Packaged Goods Organizer\n========================\n";
my %val;my $total=0;
DO:{
BAR : print "Barcode : ";$_=<>;chomp;last if ($_ == "0");
if (($_ >= 10000000000)|| ($_ < 1000000000)||/[^0-9]/){
print "Bad input (numbers only and between 1000000000 and 9999
+999999)\n";
goto BAR;
}else{
Price : print "Price : ";$val{$_}{"Price"}=<>;chomp($val{$
+_}{"Price"});
do{print "Numbers only\n";goto Price} if ($val{$_}{"Price"}=~
+/[^0-9\.]/);
Quant : print "Quantity : ";$val{$_}{"Quantity"}= <>;chomp($v
+al{$_}{"Quantity"});
do{print "Numbers only\n";goto Quant}if ($val{$_}{"Quantity"}=
+~ /[^0-9]/);
}goto DO;
};
print "\n\n\t\tGoods in Stock\n\t\t==============\nBarcode Price
+Quantity Value\n-----------------------------------\n";
foreach (sort keys %val){
format STDOUT =
@<<<<<<<<<<<<<$@<<<<<<<<<$@<<<<<$@
$_, $val{$_}{"Price"}, $val{$_}{"Quantity"}, $val{$_}{"Price"} * $val{
+$_}{"Quantity"}
.
write STDOUT;
$total += $val{$_}{"Price"} * $val{$_}{"Quantity"};
}close (STDOUT);
format STDOUT =
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<$@
"-----"
Total value good in stock>>>>>>>$@
$total
.
write STDOUT;
OUTPUTFormat STDOUT redefined at C:\Documents and Settings\\My Documents\per
+ltest
\Perl-1.pl line 28.
Packaged Goods Organizer
========================
Barcode : 1231231231
Price : 21
Quantity : 2
Barcode : 1231231232
Price : 44
Quantity : 2
Barcode : 0
Goods in Stock
==============
Barcode Price Quantity Value
-----------------------------------
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<$-
Total value good in stock>>>>>>>$0
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<$-
Total value good in stock>>>>>>>$4
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<$-
Total value good in stock>>>>>>>$1
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.