There's a bunch of spoilers here so click readmore to read them.
  • 1. I knew it was a trick using @_'s aliasing but I didn't pick up the glob assignment until I saw what BrowserUK did.
  • 2. {foo;redo}
  • 3a. $foo=*foo;$foo->[1]=$foo->{1}=\undef
  • 3b. I started fiddling with $foo=[(\!1)x2];*{"$foo"}=sub{!aye}' but was stopped by perl complaining that $foo was an array reference. I just wanted it to call the function with the name of its strinfied reference but I didn't see an immediate way around it.
  • 4. dump
  • 5. sub foo { my $x if 0 }
  • 6. $x = \1; $y = "$x"; $$y = 2
  • 7. $foo=*STDOUT{IO}
  • 8. I'm not sure how to read this. It is invalid to assume that either post increment would occur before each other - this is one of the cases where "undefined execution order" really comes into play. Now obviously, the actual order is defined by the optree which is defined by the implementation in which the first post increment (lexically) is going to execute first. So in which light am I supposed to solve this? The fiddly bits of the implementation (which in this case I'm not sure anyone is supposed to expect anything in particular) or the implementation's promise which is unspecified?
    Update 1*foo=$|;$foo=1 This answer assumes things about perl that I'm damned if I'll admit that this is a fair question. This particular behaviour is officially undefined (as to much of the rest of perl which is undefined by ommision).
  • 9a. $0=1;$foo=0
  • 9b. I'm stumped.
  • 10. I didn't see how to do this in twenty-six characters but here's a forty-five character solution: $"=::;${"@{[map 56922&2**$_?'y':x,0..15]}"}=1. I went on to start playing with ORing the bittests into the string value 'x' and got bored. print "@{[map(q[x]|q[].!(56922&2**$_),0..15)]}"
  • 11. I got tired and while I'm still probably stumped, I don't have the initiative anymore.

In reply to Re: How's your Perl? by diotalevi
in thread How's your Perl? by xmath

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.