Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Dying and Swearing

by Abigail (Deacon)
on Jun 01, 2001 at 10:47 UTC ( #84863=obfuscated: print w/replies, xml ) Need Help??

eval {die [[qq [Just another Perl Hacker]]]};; print ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]

-- Abigail

Replies are listed 'Best First'.
"Dying and Swearing" explained
by BooK (Curate) on Jun 01, 2001 at 17:09 UTC

    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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://84863]
Approved by root
[marto]: Even with shell command recall I find it less time consuming to do such things in a file.
[marto]: I very seldom use one liners for anything which isn't utterly trivial
[Discipulus]: i'm wise enough to never use my oneliners
[Discipulus]: anyway marto, i read th CB logs.. osteopat is what you need

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-09-22 08:36 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (260 votes). Check out past polls.