Quiz 3 Solution

CS 29

40 pts., Mar. 13

For the multiple choice questions, circle the letter corresponding to your answer.

  1. (10 pts.) What does the following perl program print?
    #!/usr/contrib/bin/perl -w
    
    @list = ("June", "May", "August", "December", "January", "September");
    
    $list[3] = "March";
    $list[0] = "October";
    $list[4] = "April";
    
    print "$#list\n\n";
    
    $i = 1;
    while ($i <= 4)
    {
        print "$list[$i]\n";
        $i = $i + 1;
    }
    
    exit 0;
    

    This is printed:

    5
    
    May
    August
    March
    April
    

  2. (5 pts.) What is a character class?

    A set of characters used in matching and considered to be of a single type. Examples:

    1. [aeiou] --- lowercase vowels.

    2. [A-Z] --- uppercase letters.

    3. [0-9] --- digits.

  3. (5 pts.) What does the translation tr/A-Z/a-z/ accomplish?
    1. Convert all letters to uppercase.
    2. Convert all letters to lowercase. (Answer)
    3. Convert A's to a's and Z's to z's.
    4. Nothing.

  4. (5 pts.) What operation symbol is used to apply a translation?
    1. =~ (Answer)
    2. ~=
    3. =
    4. ~
    5. None of the above.

  5. (5 pts.) Which of the following is not an example of character formatting?
    1. Bold
    2. Italic
    3. Blink
    4. Underline
    5. None of the above. (Answer)

  6. (5 pts.) Items in an unnumbered list are preceded by
    1. bullets. (Answer)
    2. arrows.
    3. numbers.
    4. letters.
    5. dots.

  7. (5 pts.) What is the fastest way of selecting a line?
    1. Dragging the mouse over it, from one end to the other.
    2. Double clicking it.
    3. Clicking before it. (Answer)
    4. Clicking after it.
    5. None of the above.


Thomas P. Kelliher
Thu Mar 20 12:38:24 EST 1997
Tom Kelliher