Earlier this evening I was given a technical Perl test for a potential new job. Most of the questions were pretty straightforward, but I thought you might be interested to see this one:
What does the following code print out
@a = ("a", 1, "b", 2, "c", 3); $i = 0; grep($foo{$_} = $a[$#a - $i++], @a); print $foo{"c"}, "\n";
Secondly, what is an easier way to populate %foo?
I think I came up with pretty good answers for both parts, but I'd be interested to hear what you think.
--"The first rule of Perl club is you don't talk about Perl club."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Tuesday Evening Code Quiz
by tye (Sage) on Oct 31, 2001 at 02:34 UTC | |
by tilly (Archbishop) on Oct 31, 2001 at 02:42 UTC | |
|
Re: Tuesday Evening Code Quiz
by blakem (Monsignor) on Oct 31, 2001 at 02:06 UTC | |
by davorg (Chancellor) on Oct 31, 2001 at 02:08 UTC | |
by blakem (Monsignor) on Oct 31, 2001 at 05:17 UTC | |
|
Re: Tuesday Evening Code Quiz
by japhy (Canon) on Oct 31, 2001 at 02:37 UTC | |
|
Re: Tuesday Evening Code Quiz
by dws (Chancellor) on Oct 31, 2001 at 02:19 UTC | |
by Maestro_007 (Hermit) on Nov 01, 2001 at 00:29 UTC | |
|
Re: Tuesday Evening Code Quiz
by pixel (Scribe) on Oct 31, 2001 at 02:25 UTC | |
|
(jeffa) Re: Tuesday Evening Code Quiz
by jeffa (Bishop) on Oct 31, 2001 at 02:41 UTC | |
|
Re: Tuesday Evening Code Quiz
by maverick (Curate) on Oct 31, 2001 at 02:08 UTC |