All pastes #835842 Raw Edit

Miscellany

public text v1 · immutable
#835842 ·published 2007-12-29 01:59 UTC
rendered paste body
#!perl 

#Higher or lower game by TheDead1! just follow what it says :)
# \$n = $n \$ran = $ran \$many = $many\n


sub get {
	$n = undef;
	print "Guess a number between 1 and the number you enterted:" . $n . "\n";
	chomp($n = <STDIN>);
	$n;
}
sub h_or_l {
	if ("$n" < "$ran") {
		print "Higher.\n";
		$n = undef;
	}
	else {
		print "Lower.\n";
		$n = undef;
	}
}

print "How many numbers to chose from?\n$many";
chomp($many = <STDIN>);
$ran = int(rand($many));

while ($n != $ran) {
	$n = undef;
	$n = &get;
} continue {
	if ($n != $ran) {
		&h_or_l;
	}
	else {
		print "You are a winner!\n";
	}
}