Perl Christmas Quiz

Paul Makepeace paulm at paulm.com
Fri Dec 12 15:00:16 GMT 2008


On Fri, Dec 12, 2008 at 2:24 PM, Robin Berjon <robin at berjon.com> wrote:
> On Dec 12, 2008, at 13:56 , Paul Makepeace wrote:
>>
>> On Fri, Dec 12, 2008 at 12:43 PM, Fahad Khan <fahad.a.khan at hotmail.com>
>> wrote:
>>>
>>> In my baby perl.
>>>
>>> sub intersect
>>> {
>>>  my ($a, $b) = @_;
>>>  my ($c, $d) = ({}, []);
>>>  foreach (@$a) { $c->{$_}->[0]++}
>>>  foreach (@$b) { $c->{$_}->[1]++}
>>>  while( my ($k, $v) = each %$c ) {
>>>      my ($i, $j) = @$v;
>>>      for(my $x=0; $x < ($i < $j ? $i : $j); $x++) {push @$d, $k}
>>>  }
>>>  return $d;
>>> }
>>
>> Do not apply for a job with that code :-)
>
> Not that I'm hiring or that I can't see issues with the code above, but the
> guy did state he had "baby perl" and then posted his proposed solution to a
> list famous for being full of Perl luminaries. Curiosity, guts, willingness
> to learn — that's a CV I'd look at.

Fair enough, and not the place to make comments. I think I've just had
one too many interview candidates in recent memory who have named
their functions "func" and used variable names like "foo", "bar", etc.

Free interviewer's hint: DO NOT DO THIS.

P, who does his best to objectively review the rest of the candidate's
efforts, but by god, it can be hard sometimes...



More information about the london.pm mailing list