renshanshan 发表于 2018-8-31 09:43:13

Perl Learning - 19 (last, next, redo, &&, ||)

Exercise: Write a program, ask user to input a number between 1 and 100 to match the given randon digit. If high or low tell him about it and retry, if matches or user inputs quit/exit/enter then the program ends.  #!/usr/bin/perl
  $num=int(1 + rand 100);
  print "Please guese the number between 1 and 100: ";
  while(){
  chomp if $_ ne "\n";
  exit if $_==$num || /quit|exit|\n/;
  if($_>$num){
  print "Too high, please retype: ";
  }elsif($_
页: [1]
查看完整版本: Perl Learning - 19 (last, next, redo, &&, ||)