PJF’s Guessing Game 

use feature qw(switch say);
my @guessed;
my $num = int(rand 100)+1;
my $out = OutOfRange->new(1,100);

while (my $guess = <STDIN>) {
    chomp $guess;
    given($guess) {
        when (/\D/)      { say "Give me an integer" }
        when ($out)      { say "Guess out of range" }
        when (@guessed)  { say "You've tried that"  }
        when ($num)      { say "Just right!"; last  }
        when ($_ < $num) { say "Too low";  continue }
        when ($_ > $num) { say "Too high"; continue }
        push(@guessed,$_);
    }
}