Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
| 1: | Given the following code, what's left in @A afterward:
@A=qw(oats peas beans); shift @A; push @A, "barley"; pop;
|
| 2: | What does printf("%18.3f", $a) do?
|
| 3: | If tr/a–z/A–Z/ is run against a string, will tr/A–Z/a–z/ restore the string to its original form?
|
| A1: | 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 @_, which causes nothing to happen to @A. |
| A2: | c. If you guessed a, you didn't count the decimal point, which occupies a position in the total (18=14+1+3). |
| A3: | 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. |