7 open CM, "commodmap" or die $!;
9 m/^(\S.*\S)\t(\d+)$/ or die;
14 %stallkinds= qw(A Apothecary
24 $!=0; my $l= <STDIN>; die $! unless defined $l;
25 die $! if STDIN->error;
27 print "GOT FOR $w LINE [$l]\n"
35 my $t= tell STDIN; $t>=0 or die $!;
36 my $r= read STDIN,$b,2; die $! if STDIN->error;
38 my $v= scalar unpack "v", $b;
39 printf "GOT AT 0x%x INT FOR %s VALUE %d 0x%x\n", $t, $w, $v, $v
45 my ($what,$ary,$ix) = @_;
47 return $got if defined $got;
52 printf "# Version: \"%s\"\n", getline("version");
53 $nstalls= getline("nstalls")+0;
55 while (@stalls < $nstalls) {
56 $_= getline("stall name ".(@stalls+1));
59 $sk= $stallkinds{$kind};
60 die "kind $kind in $_ ?" unless defined $sk;
65 unshift @stalls, undef;
69 foreach $bs qw(Buy Sell) {
70 $alloffers_want= getint("Buy ncommods");
72 while ($alloffers_done < $alloffers_want) {
73 $commodix= getint("Buy $alloffers_done/$alloffers_want commodix");
74 $offers= getint("Buy $commodnum offers");
75 for ($offernum=0; $offernum<$offers; $offernum++) {
76 $stallix= getint("Buy $commodnum $offernum stallix");
77 $price= getint("Buy $commodnum $offernum price");
78 $qty= getint("Buy $commodnum $offernum qty");
81 inmap('commod',@commodmap,$commodix),
82 inmap('stall',@stalls,$stallix)) or die $!;
83 if ($bs eq 'Sell') { print "\t\t" or die $!; }
84 printf("\t%d\t%d", $price, $qty) or die $!;
85 if ($bs eq 'Buy') { print "\t\t" or die $!; }
88 die if $alloffers_done > $alloffers_want;
94 STDIN->error and die $!;