in reply to spaceship japh

Just looking at it, i see first you have
*{'\''}=sub{die'just another perl hacker'};
which assigns the anon sub to a typeglob (or something like this) then you use a symbolic reference later to call it again. What i dont understand is where the bless comes in..?

Replies are listed 'Best First'.
SPOILER: spaceship japh
by domm (Chaplain) on Aug 19, 2002 at 19:14 UTC
    assigns the anon sub to a typeglob

    that's true.

    *{'\''}

    nearly. The name of the typeglob is \'\n, that is: Backslash-SingleQuote-Newline (that means you can have sub-names in perl that contain a Newline!)

    So, what happens is:

    *{'\' '}=sub{die 'just another perl hacker '};

    Assign the anon sub to the typeglob \'\n.

    bless&{'\' '}

    bless something. But what? The return value of the soubroutine \'\n.

    So the sub gets called. But it dies with the error-message 'just another Perl hacker'. Because the message ends in a newline, the ", at scriptname line blabla"-part is skipped.

    As the script dies here, bless is actually never executed.

    Resumee:

    • you can put newlines (or nearly anything else) in var-names using typeglobs
    • you can print without printing using die "message\n"
    -- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}