where is the error in this perl code -
my $secret = int(1+rand(100)); loop: { print "please enter guess 1 100: "; chomp(my $guess = <stdin>); $found_it = 0; given( $guess ) { when ( ! /\a\d+\z/ ) { "not number!" } when ( $_ > $secret ) { "too high!" } when ( $_ < $secret ) { "too low!" } default { "just right!"; $found_it++ } } last loop if $found_it; redo loop; }
it looks me whatever using isn't recognizing newer keywords using.
if aren't already, enable them with:
use 5.010; # or higher # or use feature 'switch';
in addition, on newer perl versions, need say
no warnings 'experimental::smartmatch';
since implicitly using smartmatch, , way works planned change in future perl version.
Comments
Post a Comment