#!/usr/bin/perl use CGI ':standard'; use CGI::Carp "fatalsToBrowser"; use strict; use warnings; my $i = 1 + (param('i') || 0); my $firstroll1 = param('roll1'); my $firstroll2 = param('roll2'); print header; my $dice1 = 1 + int rand 6; my $dice2 = 1 + int rand 6; print "($i) $dice1, $dice2
"; if (!$firstroll1 || !$firstroll2) { $firstroll1 = $dice1; $firstroll2 = $dice2; my $sum = $dice1 + $dice2; if ( $sum == 7 || $sum == 11 ) { print "you win"; print qq{
play again?}; exit; } elsif ( $sum == 2 || $sum == 12 ) { print "you lose"; print qq{
play again?}; exit; } } else { if ($dice1 == $firstroll1 && $dice2 == $firstroll2 ) { print "match"; print qq{
play again?}; exit; } elsif ($dice1 == $firstroll2 && $dice2 == $firstroll1 ) { print "match"; print qq{
play again?}; exit; } } print qq{Roll Again?};