IWA-HWG Perl Course. Week 1 Quiz

  1. What does Perl stand for? (the true definition, please)

    Perl stands for "Practical Extraction and Report Language." (Learning Perl, p. 3)

  2. What are the two basic data types in Perl?

    Perl has two basic data types: number and string. (Learning Perl, p. 18) Internally numbers in Perl are represented as floating point numbers.

  3. What is the chomp operator used for?

    When using <STDIN> (standard input), which is typically set up to take information entered by some user from the keyboard, the user indicates that he or she has finished by hitting the Enter key. The resulting input string variable's value includes a new line character at the end. The chomp operator takes a string variable and if that variable's value has a new line character at the end, then chomp removes it. (Learning Perl, p. 34)

  4. What is variable interpolation?

    There are two ways to signify the beginning and end of a string: 1) single quotes, and 2) double quotes. The double-quote version allows for a variable substitution scheme known as variable interpolation. In this scheme the double-quoted string may contain variable names which begin with a dollar sign ($). When such a string is assigned to a string variable or printed, the variable's value is substituted into the string in place of the variable's name. For example, the following code

            $player1 = "Johnny";
            $player2 = "Ronny";
            print "$player1, it is your turn.";
        
    prints Johnny, it is your turn.

    The same effect can be achieved with the concatenation operator (.) concatenating string literals and variable values together. However, the latter version of the code can be quite tedious and error prone. (Learning Perl, p. 28)