* { '\' '}=sub{die 'just another perl hacker '};bless&{ '\' ' }
Be careful to keep the line-breakes as-is when copy'n'pasting!

Inspired by a small bit of SelfGOL by TheDamian

Notice the absence of print and the rather strange way of calling bless with only one argument.

-- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

Replies are listed 'Best First'.
Re: spaceship japh
by BUU (Prior) on Aug 18, 2002 at 15:19 UTC
    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..?
      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$_.$/}