As part of our continuing crusade against sanity, we of #perlhelp (EFnet) have created a modest perl quiz to test for all the skills required to make the maintainance programmer voluntarily leap into the gaping chasm of madness. We hope it will reinforce everyone's appreciation of our favorite language, by itself and as a tool towards this noble goal.   ;-)

Only those who know and truly understand the answers to all these questions can call themselves [insert awesome title here].

For all exercises: no fork/exec/system/qx/open, no cmdline options, no user input, no modules, no tie, no bless, no %SIG. Make sure you don't depend on random factors, such as exact values of addresses. All solutions should be executable from the cmdline using perl -e For extra points, try to make them work under strict (warning: for one exercise no strict solution is known (yet))
UPDATE Thanks to mauke, strict solutions are now known for all exercises! :-)
Exercise 1: Create an array @x such that changing $x[0] also sets $x[1] to the same value Exercise 2: Given a pre-declared function "foo", write a code snippet that invokes it in an infinite loop; in 10 chars Exercise 3a: Create $foo such that \$foo->[1] == \$foo->{1} Exercise 3b: Create $foo such that \$foo->[1] == \$foo->(1) You must use different solutions for the two Exercise 4: Dump core in 6 chars Exercise 5: Create a static variable lexically scoped to a sub, and no wider than that. It's ok if it blows up under recursion Exercise 6: Create $x, $y such that $x eq $y && $$x ne $$y Exercise 7: Create $foo such that fileno($foo) && !*$foo Exercise 8: Create $foo such that ($foo^=0)++ eq $foo++ Exercise 9a: Create $foo such that eval(q[$$foo]) != eval(q[0+$$foo]) Exercise 9b: Create $foo such that eval(q[$$foo =~ / /]) && !$$foo Exercise 10: Make $x::y::x::y::y::x::y::x::x::y::y::y::y::x::y::y true in 26 chars of code Exercise 11: Make <STDOUT> eq <+STDOUT> in 25 chars Bonus Exercise: The code snippet 'sub foo{} goto +foo' produces an error: "Can't find label SCALAR(0x31c70c)" (the address may vary) Where does that ref come from? What does it point to?

Please black-box solutions/spoilers so people can safely read discussion without seeing all the answers. (for example use: <table bgcolor="#00000000"><tr><td><font color="#00000000">Text goes here</font></table>)

UPDATE: clarification of exercise 5: "static variable" means a variable whose value is retained across multiple invocations of the sub (like static vars in C), and being "scoped to a sub and no wider" means that the standard solution { my $x; sub { ... } } doesn't qualify, because $x is one block wider than the sub. (it is static though)
UPDATE: minor reformatting to make everything fit in 70 columns
UPDATE: they're designed for 5.8, though most probably have solutions on older versions too.

UPDATE: Strict solutions are now available for all exercises.

UPDATE: (21-7-2004) How's your Perl? (II)

This waste of time is sponsored by:
#perlhelp - Where people with no life teach people with no clue.