#!/usr/local/bin/perl


# first, we create a variable that will hold our input
# Note: '=' is an assignment operator; it assigns
# the right-side value to the left-side variable

$input = ""; # Initialize to empty string. Good practice to first set
             # your variables to some empty, zero, or null value.
             # All Perl statements must end with a semicolon.


# 'print' is Perl built-in function; it takes a 
# variable or literal value (in this case, a string)
# and prints it to screen. 
print "\nGuess a number from 1 to 5.\n";
print "Type \'q\' to quit.\n\n";
print ">>> ";


# wait for input:
# while the program is running, it will return to this
# point and wait for input
while (<STDIN>)  #Standard Input <STDIN> can be abbreviated as <>.
{
    $input = $_;   # put the input into variable
    chomp($input); # the input includes the return character
                 # from ENTER; chomp() is Perl built-in 
                 # function removes any 'white space'
                 # (space and new-line characters, tabs, etc.)
                 # from a string
 
  # ----------------- write your code here --------------- #
    if ($input eq 'q' ) {
        print "You are exiting the loop\n";
        last; #Special exit loop command.
    }
 
    $magicNum = 3;
    if ($input == $magicNum) {
        print "You Win A Vacation in Florida!\n";
        exit(0);
    }
    elsif ($input > 0 && $input < 6) {
        print "Too bad, try again.\n";
    }
    else {print "Pretty strange input! But go again.\n";

      }



  
  # ----------------------------------------------------- #
  
    print ">>> ";
}
