hola world.
a wave of nostalgia overcame me when i read the
posting re: punnet squares, & i offer the following
wee map-fest in penance for the sundry wrongs & misdemeanors in the classroom of biology teacher mr robinson...
it does the trick in
a fairly simple way, made more complicated by
the presence of pesky column and row titles.
if i wanted to do something with the combinations
generated, like count frequencies, i'd get rid of the unshift's, which are
only there to deal with the row and column titles.
the venerable getopt::long module is used for arg
capture.
# i am not strict
use Getopt::Long;
GetOptions("f=s@" => \@dadAlls,
"m=s@" => \@mumAlls,
"help" => sub {
print "psquare: --f (male allele) --m (female allele)\n"; exit; });
unshift @mumAlls, ""; # for titles.
@psquare = map { my $current = $_; [ map { sprintf("%-10s",$current .
+$_) } @mumAlls ] } @dadAlls;
unshift @psquare, [map { sprintf("%-10s", $_) } @mumAlls];
map { print join "", @$_; print "\n"; } @psquare;
hope that helps.