+my $parse_numeric= sub {
+ # returns (mass,volume,emsg)
+ my ($string,$default)= @_;
+
+ my @mve= (undef,undef,undef);
+
+ if ($string !~ m/\d/) {
+ return (undef,undef,
+ 'Adjustments to capacity must contain digits.');
+ }
+
+ my $def= sub {
+ my ($ix,$what,$val) = @_;
+ if (defined $h->{$what}) {
+ $mve[2]= "\`$string' specifies $what more than once.";
+ }
+ print STDERR "SET $what $val\n";
+ $mve[$ix]= $val;
+ };
+
+print STDERR "PAN \`$string'\n";
+ local $_;
+ foreach $_ (split /\s+/, $string) {
+ print STDERR "ITEM \`$_'\n";
+ next unless length;
+ if (m/^([1-9]\d{0,8})l$/) {
+ $def->(1, 'volume', $1);
+ } elsif (m/^([1-9]\d{0,8})kg$/) {
+ $def->(0, 'mass', $1);
+ } elsif (m/^([1-9]\d{0,5}(?:\.\d{0,3})?)kl/) {
+ $def->(1, 'volume', $1 * 1000);
+ } elsif (m/^([1-9]\d{0,5}(?:\.\d{0,3})?)t/) {
+ $def->(0, 'mass', $1 * 1000);
+ } else {
+ $mve[2]= "Cannot understand item \`$_'".
+ " in numeric capacity";
+ }
+ }
+# foreach my $ix (qw(0 1)) {
+# $mve[$ix]= $default unless defined $mve[$ix];
+# }
+ return @mve;
+};
+
+my @mv_names= qw(mass volume);
+my $canon_numeric= $h->{'canon_numeric'}= sub {
+ print STDERR "CANNUM @_\n";
+ my $sep= '';
+ my $out= '';
+ foreach my $ix (qw(0 1)) {
+ next unless defined $_[$ix];
+ $out .= $sep; $sep= ' ';
+ $out .= sprintf "%g%s", $_[$ix], (qw(kg l))[$ix];