You'll find the quiz at http://www.ddj.com/linux-open-source/201801549 (assuming you use a browser that withstands all the "neat stuff" that site does).
Quizzes like this always seem to irritate me. It sometimes seems as if they go out of their way to be ambiguous and/or imprecise. So I decided to vent, with your cooperation. Note that if I didn't find something to complain about, I made something up. If you are the author of this quiz, please try not to take it too personally.
My answers and comments to questions 1-25:
But scalar isn't a data type, or if it is, perl only has two data types, list and scalar. And there are fewer ways you can use a list than a scalar, so the correct answer is "list".
"Bottom" of an array is a horribly ambiguous term. But of the two, I would guess most would say "shift".
"items"? I thought we were calling them scalars. "character order"? Do you mean like sort { chr($_) cmp chr($_) } ? I'm used to seeing the term "lexicographic order". Trivia Q: when does $^O eq "linux" produce a tainted result?
My personal preference. But I think both printf and format are "often used".
Actually, I'm told that on sufficiently old perls, /IBM/i is slower than /[Ii][Bb][Mm]/. But I won't share my thoughts about people who would do the latter.
Often, a regex match is handier.
Or -W, or -Mwarnings, or ...
Though it's used way too often in cases where "if" would be clearer. I've seen unless's that would be not much worse as
.EXPR and last while not(condition)
Why are we using a non-lexical filehandle KAREN? Blech.
I only knew this by process of elimation, knowing what -s, -l, and -S were. Guess I'm not enough of a unix geek.
Change what about the working directory? I'd use chown $uid, $gid, "." or chmod $perm, ".", myself.
"access"? How about "remove and return"? I would have guessed "[0]". (Except when $[ is changed. But don't do that.)
Except that last is not an operator. And doesn't work on do loops. And isn't immediate, since the usual end-of-scope processing applies.
Um, no. POSIX::_exit(). What's a "standard error", and why "even if"? "make sure" isn't met if there's an eval, if it's in a thread, if it's in embedded perl, if a destructor resets $@, etc.
I guess. I'm not sure in what sense it's only "like" sime searching/ pattern matching.
Well, "declare" a subroutine. The definition part is optional, and can be done without sub.
Using "use Fatal 'closedir';", are you?
Yucky inconsistent whitespace, there. There's an important difference, at least under warnings.
Perhaps you're thinking of the POSIX unlink command? rm does a whole lot more (in addition to having automatic generation of an error message, a feature shared by unlink(1)). Oh, perhaps you are doing
, too.use Fatal 'unlink';
Function, huh. I thought we were referring to built-ins as operators. Counting back, I see the score so far, is 7 to 2 in "operator"'s favor.
What is "value" here? A line? A byte? And what is "keyboard"? If there were a common need to read from one, I'd assume there'd be a /dev/keyboard. But there isn't. Probably the answer to the intended question is something like
do { open(my $tty, "/dev/tty") && readline($tty) or die "nope: $!" + }
Except that requires execute access to the directory the file is in and any other directories mentioned in the path given.
Or, more generically, File::Copy::move.
Counterexamples:
print @x; # where's the "uninitialized value in print" warning? sub TIESCALAR { bless{} } sub FETCH { 42 } tie $x, "main"; print $ +x
For those counting, the built-in score is now: operator: 7, function: 5. (Yes, I didn't count "last", which the doc (mostly) calls a "command", or m, which I don't count as a built-in.)
Half-time! All my guesses as to the intended correct answer were right so far!
Meta-comments: The bit where answers are given as letters A-D but the multiple-choice questions are given using a plain ol tag (rendered for me as 1-4) is a bit offputting. Especially since the first question has the answer "scalar, C", when scalar was answer 2. All the other answers so far do correspond as chr(64+$ans) (except under EBCDIC).
The bit where the answer "<STDIN>" disappears into the mists of HTML interpretation was cute. Entities, guys, entities.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Snarky comments on the ddj perl quiz
by liverpole (Monsignor) on Aug 23, 2007 at 01:10 UTC | |
by ysth (Canon) on Aug 23, 2007 at 01:17 UTC | |
by djp (Hermit) on Aug 24, 2007 at 04:34 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by samizdat (Vicar) on Aug 23, 2007 at 12:35 UTC | |
by syphilis (Archbishop) on Aug 23, 2007 at 14:33 UTC | |
|
Re: Snarky comments on the ddj perl quiz (nein)
by tye (Sage) on Aug 23, 2007 at 01:13 UTC | |
by ysth (Canon) on Aug 23, 2007 at 01:22 UTC | |
by clinton (Priest) on Aug 23, 2007 at 09:01 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by ruoso (Curate) on Aug 23, 2007 at 11:00 UTC | |
by ysth (Canon) on Aug 23, 2007 at 11:21 UTC | |
by DrHyde (Prior) on Aug 24, 2007 at 09:27 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by rvosa (Curate) on Aug 23, 2007 at 14:32 UTC | |
by polettix (Vicar) on Aug 23, 2007 at 22:29 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by CountZero (Bishop) on Aug 23, 2007 at 20:56 UTC | |
by tripa (Novice) on Aug 23, 2007 at 21:30 UTC | |
by CountZero (Bishop) on Aug 24, 2007 at 05:12 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by ysth (Canon) on Aug 23, 2007 at 00:35 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by rvosa (Curate) on Aug 23, 2007 at 14:27 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by rvosa (Curate) on Aug 23, 2007 at 14:28 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by technojosh (Priest) on Aug 23, 2007 at 21:16 UTC | |
|
Re: Snarky comments on the ddj perl quiz
by Argel (Prior) on Aug 27, 2007 at 23:14 UTC | |
by Argel (Prior) on Aug 28, 2007 at 21:49 UTC | |
by runrig (Abbot) on Aug 30, 2007 at 03:46 UTC | |
by BrowserUk (Patriarch) on Aug 30, 2007 at 04:22 UTC | |
by eric256 (Parson) on Aug 30, 2007 at 00:00 UTC | |
by Argel (Prior) on Aug 30, 2007 at 19:11 UTC | |
by tye (Sage) on Aug 30, 2007 at 00:47 UTC | |
by BrowserUk (Patriarch) on Aug 30, 2007 at 01:40 UTC | |
by tye (Sage) on Aug 30, 2007 at 02:19 UTC | |
| |
by Argel (Prior) on Aug 30, 2007 at 19:23 UTC | |
by Anonymous Monk on Aug 29, 2007 at 09:26 UTC | |
| |
|