Jump to content

How's your Perl?


Guest

Recommended Posts

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...