Hey, so I'm fairly new to perl and was experimenting with a random number generator and some other things as a sort of intelligence test, long story short, I didn't make it very far. I'd like to ask the user if they accept the challenge, but also have it loop and ask again for user-input if a non-acceptable answer is entered. Here is the segment of my code where the error "Can't call method "untill" without a package or object reference"
#!usr/bin/perl use strict; use warnings; use diagnostics; my $range = 100; my $random_number = int(rand($range)); my $answer = 0; print "Do you accept this challenge? "; Do { chomp (my $response = <>); if ($response eq 'yes' || 'Yes' || 'YES' || 'y') { $answer = $answer + 1; } elsif ($response eq 'no' || 'No' || 'NO' || 'n') { $answer = $answer + 2; } else { print "Please respond with 'yes' or 'no'\n\n"; } }until $answer > 0;
In reply to User input check 'Do until' loop by Ahten
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |