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; } 

this code cannot run. cannot find mistakes are! errors in pic.

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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -