in reply to Evil Interview Questions

if someone gets them wrong, however, you can't tell whether they know Perl well or not

I'd say the first two are important to know.

The next two fall into the "I wouldn't do that, therefore that code is suspect. I'm not sure what it does, but documentation needs to be added to explain what it's doing and/or it needs to be refactored."

The last one is just plain unimportant. The code dies quite loudly and reproduceably. A better discussion would be how to fix it.

Replies are listed 'Best First'.
Re^2: Evil Interview Questions
by kyle (Abbot) on Feb 09, 2008 at 04:33 UTC

    I wouldn't do that, therefore that code is suspect.

    Those two were the map vs. for and return 11 unless shift...

    I also avoid map in void context (it clashes with my concept of map). Until recently, I'd have rewritten the map into the for without another thought. Now I know that there is a difference between them, if and only if the context is important to what's happening in the block. I don't expect I'd run into that case often, but I do expect I'd spend a long time figuring out what had happened if I did (and didn't already know the answer to this question).

    I've seen the simple return $x unless $y construct come up a couple times here, and there are probably more. I suspect it gets written into "real" code inadvertently. I think it's a good thing to be able to recognize. Yes, it needs a rewrite, but you have to know what it does to be sure you haven't broken anything after that.

    The last one is just plain unimportant.

    I wondered if the candidate knew that for my $x turns $x into an alias for each item. I agree this wasn't a very good question; it's my least favorite out of the bunch.