chiark / gitweb /
De-%ify a big chunk of perl
[ypp-sc-tools.main.git] / yarrg / Commods.pm
index 27e06e867e39bf56d5cfd9ed65f49a37b881b726..dff539d87166a7e3b7e114d6a0d9d68be6c0f06c 100644 (file)
@@ -122,13 +122,13 @@ sub parse_info1 ($$) {
 #print "ca($s)\n";
        if ($s !~ m/\%(\w+)/) {
            my ($name, $props) = $s =~
 #print "ca($s)\n";
        if ($s !~ m/\%(\w+)/) {
            my ($name, $props) = $s =~
-               /^(\S[^\t]*\S)\t+(\S[^\t]*\S)$/
+               /^(\S[^\t]*\S)(?:\t+(\S[^\t]*\S))?$/
                or die "bad commodspec $s";
            my $ucname= ucfirst $name;
            $commods{$ucname}{Srcs} .= $ss;
            my $c= $commods{$ucname};
            $c->{Volume}= 1000;
                or die "bad commodspec $s";
            my $ucname= ucfirst $name;
            $commods{$ucname}{Srcs} .= $ss;
            my $c= $commods{$ucname};
            $c->{Volume}= 1000;
-           foreach my $prop (split /\s+/, $props) {
+           foreach my $prop (defined $props ? split /\s+/, $props : ()) {
                if ($prop =~ m/^([1-9]\d*)(k?)g$/) {
                    $c->{Mass}= $1 * ($2 ? 1000 : 1);
                } elsif ($prop =~m/^([1-9]\d*)l$/) {
                if ($prop =~ m/^([1-9]\d*)(k?)g$/) {
                    $c->{Mass}= $1 * ($2 ? 1000 : 1);
                } elsif ($prop =~m/^([1-9]\d*)l$/) {
@@ -137,7 +137,6 @@ sub parse_info1 ($$) {
                    die "unknown property $prop for $ucname";
                }
            }
                    die "unknown property $prop for $ucname";
                }
            }
-           die "no mass for $ucname" unless defined $c->{Mass};
            return;
        }
        die "unknown $&" unless defined $colours{$1};
            return;
        }
        die "unknown $&" unless defined $colours{$1};