use strict; use warnings; use Games::Cards; my $game = Games::Cards::Game->new(); my $deck = Games::Cards::Deck->new($game,'guessing'); $deck->shuffle; my $this_card = shift @{$deck->cards}; my $next_card = $this_card; my $answer = prompt(); for $this_card (@{$deck->cards}) { die ('was higher') if $this_card->value > $next_card->value and $answer eq 'L'; die ('was lower') if $this_card->value < $next_card->value and $answer eq 'H'; $answer = prompt(); $next_card = $this_card; } print "You made it to the end!\n"; sub prompt { print "Higher or lower? [H or L] "; chomp(my $ans = uc ); $ans = ($ans eq 'H' || $and eq 'L') ? $ans : 'H'; return $ans; }