X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fcheck_lossperleague;h=a37382e3a48aec5f61ae86eb2562d7c7647f50e4;hp=aaeb5b0cf381ba124fe0c1354520a57de6e680b5;hb=01bc181a77c9f44e675a4f8d1be33e2e3c252a19;hpb=099cd920655c1db6da4a1a57ec3baa30d16321d7 diff --git a/yarrg/web/check_lossperleague b/yarrg/web/check_lossperleague index aaeb5b0..a37382e 100644 --- a/yarrg/web/check_lossperleague +++ b/yarrg/web/check_lossperleague @@ -29,37 +29,35 @@ sponsored by Three Rings. - This Mason component simply defines how to interpret capacities. + This Mason component simply defines how to interpret losses per league. - -<%attr> - - -<%method preparse> +<%method execute> <%args> -$h +$string +$dbh +$debugf <%perl> -$_= ${ $h->{String} }; +$_= $string; s/^\s+//; s/\s+$//; -my $res= sub { - my ($pct,$str) = @_; - push @{ $h->{Results} }, [ $pct ]; - ${ $h->{Canon} }= "Considering expected losses of $str per league"; -}; +my ($pct,$str); if (!m/\S/) { + $str= ''; } elsif (m/^(\d{1,2}(?:\.\d{0,5})?)\%$/) { - $res->( $1 * 1.0, sprintf("%g%%", $1) ); + $pct= $1 * 1.0; + $str= sprintf("%g%%", $1); } elsif (m/^1\s*\/\s*([1-9]\d{0,4})/) { - $res->( 100.0/$1, sprintf("1/%d", $1) ); + $pct= 100.0/$1; + $str= sprintf("1/%d", $1); } else { - ${ $h->{Emsg} }= "Cannot understand loss per league \`$_'."; - return; + expected_error("Cannot understand loss per league ".escerrq($_)."."); } +return ("$str per league", $pct); +