-w; use strict; my @flip = ('H','T'); my @results; my @heads; for (1..200) { push(@results,$flip[rand(2)]); } my $head_count; foreach (@results) { if ($_ =~/H/) { print $_; $head_count++; } else { print " "; push(@heads,$head_count) if ($head_count != 0); $head_count= 0; } } $head_count = 0; print "\n\n"; foreach (@heads) { $head_count += $_; } print "The tally of heads (in a row) looks like:\n"; print join('|',@heads); print "\n"; print "The number of heads total is:\n"; print $head_count;