Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Very good one! This is what I call unreadable...

You are using a propriety of die() I didn't know of...

die() can also be called with a reference argument. If this happens to be trapped within an eval(), $@ contains the reference.

So after the eval() died $@ contains a reference to an array holding only one element, which is a reference to an array containing the string "Just another Perl hacker". But what does the print() actually print?

Let's cut the all thing in several bits: first you must know that $#{@{${@}}} equals 0. Here is why: when you see $#a, this is the value of the last array index (one less than the size of the array) of the array @a. @{${@}} is an array dereference. Since $@ is an array holding only one value, the result is 0.

We now have to understand ${${${@}}[0]}[$#{${@{${@}}}[0]}]... We recognize the underlined part as an index value. Let's calculate it.

  • ${${@}}[0] is the first element of the array reference by $@ (which is another reference to the array holding the string we want to print).
  • In $#{${@{${@}}}[0]} the underlined part is an array (dereferenced from $@). The $#<array> notation will give us the value of the last index of the array, which is 0.

With ${${${@}}[0]}[0], we are almost there. The underlined part is an array dereference, from which we want the first element.

This element is "Just another Perl hacker". QED.

In reply to "Dying and Swearing" explained by BooK
in thread Dying and Swearing by Abigail

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (4)
    As of 2018-06-24 06:07 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.