X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fcheck_lossperleague;h=a37382e3a48aec5f61ae86eb2562d7c7647f50e4;hp=41ed4b3f1a02fdb964691df18453eb6de70f4f53;hb=53dfe71f6c510ee12bbf6bdaeb3984024d34a7be;hpb=1a64a4e4703ade43ff0b26150f8128969be0ec8b diff --git a/yarrg/web/check_lossperleague b/yarrg/web/check_lossperleague index 41ed4b3..a37382e 100644 --- a/yarrg/web/check_lossperleague +++ b/yarrg/web/check_lossperleague @@ -32,34 +32,32 @@ 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} }= "$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); +