Here's my solution. Is this the kind of thing you had in mind?
#! /usr/bin/perl
use strict;
use warnings;
my @left;
my @right;
for (my $i = 0; $i <= 11; $i++) {
my $j = $i+1;
$j = 0 if $j == 12;
print "Weigh Balls $i and $j\n";
print "Enter a result for each ball as follows:\n";
print " b-b Both balls balance\n";
print " u-d Left side up, right side down\n";
print " d-u Left side down, right side up\n";
chomp( my $input = <STDIN>);
my @results = split/-/, $input;
$left[$i] = $results[0];
$right[$j] = $results[1];
}
for (my $i = 0; $i <= 11; $i++) {
if (( $left[$i] eq "b") ||
( $right[$i] eq "b")) {
print "Ball $i is normal\n\n";
} elsif (( $left[$i] eq "d" ) &&
( $right[$i] eq "d")) {
print "Ball $i is Heavy!\n\n"
} elsif (( $left[$i] eq "u" ) &&
( $right[$i] eq "u" )) {
print "Ball $i is Light!\n\n";
} else {
print "Something is FUBAR somewhere!\n";
}
}
I haven't included any error checking for input errors, etc. It's just the bare logic.
Jack