From 2cf70baa979e0c460e4e46a9c1a53677b09a1972 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 24 Aug 2009 15:37:03 +0100 Subject: [PATCH] De-%ify a big chunk of perl --- yarrg/web/routetrade | 92 +++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 12b4a89..e4e583a 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -575,42 +575,44 @@ Start at <% $islandname |h %> Sail to <% $islandname |h %> % } -% my $age_reported= 0; -% my %flowlists; -% foreach my $od (qw(org dst)) { -% foreach my $f (@flows) { -% next if $f->{Suppress}; -% next unless $f->{"${od}_id"} == $islandids[$i]; -% next unless $f->{OptQty}; -% my $price= $f->{"${od}_price"}; -% my $stallname= $f->{"${od}_stallname"}; -% my $todo= \$flowlists{$od}{ -% $f->{'commodname'}, -% (sprintf "%07d", $price), -% $stallname -% }; -% $$todo= { -% Qty => 0, -% orgArbitrage => 0, -% dstArbitrage => 0, -% } unless $$todo; -% $$todo->{'commodname'}= $f->{'commodname'}; -% $$todo->{'stallname'}= $stallname; -% $$todo->{Price}= $price; -% $$todo->{Timestamp}= $f->{"${od}_timestamp"}; -% $$todo->{Qty} += $f->{OptQty}; -% $$todo->{Total}= $$todo->{Price} * $$todo->{Qty}; -% $$todo->{Stalls}= $f->{"${od}Stalls"}; -% if ($f->{'org_id'} == $f->{'dst_id'}) { -% $$todo->{"${od}Arbitrage"}= 1; -% } -% } -% } -% -% my $total; -% my $dline= 0; -% my $show_flows= sub { -% my ($od,$arbitrage,$collectdeliver) = @_; +<%perl> + my $age_reported= 0; + my %flowlists; + foreach my $od (qw(org dst)) { + foreach my $f (@flows) { + next if $f->{Suppress}; + next unless $f->{"${od}_id"} == $islandids[$i]; + next unless $f->{OptQty}; + my $price= $f->{"${od}_price"}; + my $stallname= $f->{"${od}_stallname"}; + my $todo= \$flowlists{$od}{ + $f->{'commodname'}, + (sprintf "%07d", $price), + $stallname + }; + $$todo= { + Qty => 0, + orgArbitrage => 0, + dstArbitrage => 0, + } unless $$todo; + $$todo->{'commodname'}= $f->{'commodname'}; + $$todo->{'stallname'}= $stallname; + $$todo->{Price}= $price; + $$todo->{Timestamp}= $f->{"${od}_timestamp"}; + $$todo->{Qty} += $f->{OptQty}; + $$todo->{Total}= $$todo->{Price} * $$todo->{Qty}; + $$todo->{Stalls}= $f->{"${od}Stalls"}; + if ($f->{'org_id'} == $f->{'dst_id'}) { + $$todo->{"${od}Arbitrage"}= 1; + } + } + } + + my $total; + my $dline= 0; + my $show_flows= sub { + my ($od,$arbitrage,$collectdeliver) = @_; + % % my $todo= $flowlists{$od}; % return unless $todo; @@ -663,14 +665,16 @@ Sail to <% $islandname |h %> % } % $total= undef; % $dline= 0; -% }; -% -% $show_flows->('org',1,'Collect'); $show_total->('(Arbitrage) outlay'); -% $show_flows->('dst',1,'Deliver'); -% $show_flows->('dst',0,'Deliver'); $show_total->('Proceeds'); -% $show_flows->('org',0,'Collect'); $show_total->('Outlay'); -% -% } +<%perl> + }; + + $show_flows->('org',1,'Collect'); $show_total->('(Arbitrage) outlay'); + $show_flows->('dst',1,'Deliver'); + $show_flows->('dst',0,'Deliver'); $show_total->('Proceeds'); + $show_flows->('org',0,'Collect'); $show_total->('Outlay'); + +} + <& query_age:dataages, id2age => \%da_ages &> % -- 2.30.2