#!/usr/bin/perl

# This script simulates flipping a coin $t times and recording the result in
# the variable $c.

$t = 10000;	# Number of flips to be calculated
$c = 0;	# Counter starts at zero

for($i = 0; $i < $t; $i++) {
	$c = $c + (int(rand(2)) == 1);	# Programming trick--boolean values also
}									# integer values.  True = 1 and False = 0
									# See dotw.pl for another example of this
									# in the $IsLeapYear calculation.

print "Result: $c\n";

