Given the following code, what's left in @A afterward:
@A=qw(oats peas beans);
push @A, "barley";
What does printf("%18.3f", $a) do?
It prints a floating-point number that is 18 characters wide: 15 to the left and 3 to the right of the decimal point.
It prints a floating-point number 18 characters to the left of the decimal, a decimal point, and then 3 more digits.
It prints a floating-point number that is 18 characters wide, 14 to the left and 3 to the right of the decimal point.
If TR/a-z/A-Z/ is run against a string, will tr/A-Z/a-z/ restore the string to its original form?
c. The shift removed oats, and the push added barley to the end. The final pop was a ruse: No array was specified, so it popped something from the array @_ or from @ARGV, which causes nothing to happen to @A.
c. If you guessed a, you didn't count the decimal point, which occupies a position in the total (18=14+1+3).
b. The string "Rosebud" transformed by tr/a-z/A-Z/ becomes "ROSEBUD". TRying to transform it back with tr/A-Z/a-z/ yields "rosebud"—not the original string.
Rewrite the Hangman game from Hour 4 to use scalars instead of arrays. You can use substr to manipulate individual characters in the scalars.
Modify Listing 9.2 to read from a file instead of getting data from an array. Open the file, read the data into an array, and continue as normal. You will have to create the file on disk, of course.
© 2000- NIV