It's about half-obfuscated, deliberately. I didn't really care which magic variables I used, as they were mostly all good candidates (don't need to be declared, a first year student probably wouldn't know anything about them).

Here's my explanation:

@ARGV=();

I use the magic input operator in a moment to read from STDIN. This'll break if @ARGV has anything, so I clobber any command line arguments.

$; = "%2u * %2u = %u";

I'd have to look up $; to see what it does. It doesn't break anything, so why not use it here? This is just a format string for printf. It's also the source of the apparent bugs jptxs and tilly mention.

($_ = $. = <>);

A little bit of misdirection here. Would a beginning programmer know about $. or the magic input? I think not.

do { chomp; $! = !(defined($_)) } while ($|);

This just gets rid of the newline on $_ and sets $! to 0 ($_ is most likely defined, so I negate the result of that check). $| is 0, so it only executes once.

print join($/, map{ $!++; sprintf($;,$!,$_, ($_ * $!)) } (($.) x 10));

Here's the real meat. First, we create a ten-element list of the input. There's another subtle bug that doesn't hurt any, because $. hasn't been chomped. Perl does what I mean, though.

Next, we increment $!, which we use in the multiplier. It's at zero to start, so we need to get it to 1 before looping.

The map returns a list of strings from sprintf, with the format slots filled. The join puts them together with the contents of $/ (a newline, as we haven't messed with it) and they're printed.

There you have it. A mess of punctuation with concepts a beginning programmer wouldn't know but bugs he'd be likely to produce. Now I have to go take a shower.


In reply to Re: (jptxs)Re: I Can't Believe You People (tm) by chromatic
in thread I Can't Believe You People (tm) by chromatic

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.