Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Snarky comments on the ddj perl quiz

by ysth (Canon)
on Aug 23, 2007 at 00:26 UTC ( [id://634548]=perlmeditation: print w/replies, xml ) Need Help??

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:

Replies are listed 'Best First'.
Re: Snarky comments on the ddj perl quiz
by liverpole (Monsignor) on Aug 23, 2007 at 01:10 UTC
    I'm with you!

    One has to marvel at the lack of proofreading behind:

    What is the simplest type of data that Perl can work with? 1. element 2. scalar 3. vector 4. component and then (in the answer section): The simplest type of data that Perl can work with is called a scalar. +Answer: C.

    There wasn't any answer "C" ...?!  Oh, we're supposed to do a mental translation from numbers to letters!

    There's also a typo, in question #9:

    Which of the following commands should be used to open a filehandle na +med KAREN to an existing file named sw? 1. open KAREN ">sw"; 2. open KAREN, ">sw"; 3. open "sw" KAREN; 4. open ">sw", KAREN;

    I didn't like any of them ... the only one that works (#2) overwrites the file "sw", whereas the question implies that the file is being opened for read access.

    As does the answer (which doesn't match):

    The command open KAREN, "sw"; should be used to open a filehandle name +d KAREN to an existing file named sw. Answer: B.

    I've only read the first 16 of them, but it's not a test I'd be likely to use in an interview session.

    Oh, and one final nit:  I always think of arrays as going horizontally from left to right, but if they are vertical, then wouldn't:

    Which operator can be used to take the bottom item from an array? 1. pop 2. push 3. pull 4. plant

    Have it upside-down?  If anything, push and pop should work with the top of the array, I'd think...


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      Oh, we're supposed to do a mental translation from numbers to letters!
      I think the questions and the answers are both ol lists, and somebody's browser rendered that as 1. A. B. C. D. 2. A. B. C. D. ...
      the only one that works (#2) overwrites the file "sw"
      I noticed the inconsistency between the question and answer, but somehow read the question as "<sw". That's pretty funny.
      Well for me, 'open a filehandle TO an existing file' (strongly) implies opening the file for output. 'open FROM an existing file' implies opening for input.
Re: Snarky comments on the ddj perl quiz
by samizdat (Vicar) on Aug 23, 2007 at 12:35 UTC
    I'm reminded of the New York State education department that approved a "Forth Grade" Reader for publication, then tried to blame their approval on "consultants".

    Of course, with Presidents scraped from the bottom of a barrel...

    <8^O

    Don Wilde
    "There's more than one level to any answer."
      then tried to blame their approval on "consultants"

      Bad move ... they would have been better advised to publish a photograph of the Grade twins (Forth and Fith :-)

      Cheers,
      Rob
Re: Snarky comments on the ddj perl quiz (nein)
by tye (Sage) on Aug 23, 2007 at 01:13 UTC

    You didn't notice that they provided no correct answer to question 9?

    - tye        

      Nonsense!
      open KAREN, ">sw"; is a correct, if unfortunate, answer to the question "Which of the following commands should be used to open a filehandle named KAREN to an existing file named sw?"
      Assuming you have to choose one, and don't prefer a syntax error to success.

        Update I misread the question for the third time, and thought it was trying to open a filehandle to an existing fileHANDLE, not an existing file.

        The correct way to open a filehandle to an existing filehandle is to duplicate it:

        open KAREN, ">&sw"

        Clint

Re: Snarky comments on the ddj perl quiz
by ruoso (Curate) on Aug 23, 2007 at 11:00 UTC
    2. scalar 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".

    You know, I usually see Scalar as a data type. It's even mapped to SV* when you go to C. And no, when you consider scalar as a data type, you still have Array, Hash, Glob and Code. And yes, all of them are SV* also (the SV struct is binary compatible with all of them). Or did I miss something?

    daniel
      I say "scalar isn't a data type" because all data is either a scalar or a list of scalars, so a scalar isn't really a type of data, just like dog isn't a type of poodle.

      Internally, yes, there are data types representing hashes, arrays, opcodes, etc., but at the Perl language level, arrays, hashes, globs, and scalars are variable types, not data types. And the only thing you can do with those variables is get data from them or put it into them, and that data is always a scalar or list of scalars.

        What do you mean a dog isn't a type of poodle? How else are you going to discriminate between Tory Bliar and all the other poodles?
Re: Snarky comments on the ddj perl quiz
by rvosa (Curate) on Aug 23, 2007 at 14:32 UTC
    To add a newline to each entry (that does not already have it) as that entry is printed print "@array\n";. Answer: C.
    Erm, no:
    $ perl -e '@array=qw(a b c d);print "@array\n"' a b c d $
      That was probably the best imho: no bad wording, just a lazy attitude. But I confess that I was scared for a split second that one of them would work!

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.
Re: Snarky comments on the ddj perl quiz
by CountZero (Bishop) on Aug 23, 2007 at 20:56 UTC
    To call a subroutine named "mom", you precede the name with an ampersand: &mom. Answer: A.
    My mother will only "answer" if I precede her name with please.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Is your mom programmed in INTERCAL?
        I don't know in what she is programmed, but she programs in imperative languages!

        Jusk kiddin' mom! Yes I will clean-up my room now. May I then please go to YAPC::EU? Please mom, please?

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

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
    Both $price =+9; and $price = $price + 9; accomplishes the same thing of adding 9 to the current value of the $price variable. Answer: C.
    Erm, shouldn't that be "$price += 9"?
Re: Snarky comments on the ddj perl quiz
by rvosa (Curate) on Aug 23, 2007 at 14:28 UTC
    Answer: Set $duo equal to in the program to have it read a keyboard value (standard input).
    I assume someone forgot to escape the "<" character?
Re: Snarky comments on the ddj perl quiz
by technojosh (Priest) on Aug 23, 2007 at 21:16 UTC
    2 favorite parts:

    • Converting numbers to letters to see if i got anything right...sure its easy to figure out 1=A, I just don't want to
    • The sweet <STDIN> disappearing act.
Re: Snarky comments on the ddj perl quiz
by Argel (Prior) on Aug 27, 2007 at 23:14 UTC
    FYI, there's another thread already discussing some of the questions: DDJ Test for Perl.
      I see my post above received a downvote. If you are the person who did it I would be curious to know why? This thread and the one I linked to seem to compliment each other almost perfectly so I am really baffled at the downvote.
      -- Confused
        It was an accident. I swear. You know, sometimes you aim for the ++, but some mysterious force draws your cursor over to the -- (not enough coffee maybe? too much coffee? Or Lagavulin?). Sometimes you even notice your mistaken vote and intend to hit the +=0 before you hit submit, but forget. In the nearly seven years I've been here, it's happened to me at least twice. But not on this thread. The point being, as tye said, a single downvote doesn't mean anything. Or maybe he didn't say that...

        I would guess that it is more to do with your wording. When i first read it I heard "dude there is already a post on this subject so why did you post another one?" Granted thats not what you actually said or probably what you meant. I think it stems from your use of the FYI, that can have a negative connotation. So 'FYI' and 'there's another thread already discussing' give your post a negative feel when read as if you are pointing out to the OP that they screwed up and there was already a post about this.

        English + Human Beings + Intonation Free Text Based Communication = Miscommunication.


        ___________
        Eric Hodges

        You might find it helpful to consult the site documentation (see the "Need Help??" link at the top of each page) which notes that a single downvote on a node likely has at least as much to do with the person casting the vote as with the node voted upon.

        At the time you wrote this reply, you only had a single down-vote on the prior node. Escalating a single downvote into a yet another discussion about voting reasons often changes the types of votes you get, so the single down-vote might be the only one actually due to (one person's reaction to) just the prior node.

        If you are really curious about why someone might downvote, besides the site documentation, you can read through many, many previous discussions on voting. It sounds like you, like most, don't downvote w/o a fairly serious reason. But that is just how most monks vote, not all of them. Some down-vote all of the time and almost never up-vote, so, obviously, they down-vote for less than serious reasons (or else they think the site is chock full of serious problems, I guess). Some monks have pet peaves. And, of course, everybody can have a bad day and take it out on somebody else.

        Are you really so conceited that you can't even imagine some reason why someone might dislike your prior node? :)

        Finally, some advise: Meta-discussion points such as your "link between the threads" are usually better received if they are accompanied by some non-meta-discussion points. That is, try to contribute to the main topic of the thread if you want to make some point about the discussion itself (not the topic of the discussion).

        - tye        

        Asking why in a separate node will get you more --
        A reply falls below the community's threshold of quality. You may see it by logging in.
      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://634548]
Approved by kyle
Front-paged by gmax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-24 00:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found