#!/usr/bin/perl # https://perlmonks.org/?node_id=1226526 use strict; use warnings; while(1) { my $input; my $random_integer1 = int rand 100; my $random_integer2 = int rand 100; do { print "What is $random_integer1 - $random_integer2 = "; chomp( $input = ); } while $input != $random_integer1 - $random_integer2 and print "Sorry you're wrong, have another go.\n\n"; print "Well done.! you are correct.\n\n"; }