Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Super Spaceship Operator

by chipmunk (Parson)
on Dec 08, 2000 at 02:21 UTC ( #45627=note: print w/ replies, xml ) Need Help??


in reply to lp.hpajnilap.palinjaph.pl

Very nice! The way you mirrored the text is very pleasing, and the substitution and its reflection are very clever.

I would like to stake my own claim to having the first symmetrical JAPH, though.

This code was actually written to demonstrate a little-known operator in Perl. Of course, you're familiar with the "spaceship operator", <=>, so named because it resembles Darth Vader's TIE Fighter in Star Wars. Well, this code uses the super spaceship operator, <<=>>.

1. < 0, push @ tnirp => <<=>> <= print @ hsup ,0 > .1 Just another Perl hacker rekcah lerP rehto +na tsuJ ; print @ tnirp ;
That was written in September 1999, and was inspired by something Benjamin Holzmann wrote for The Perl Conference 3.0. There is a more complicated version which doesn't print the reflection, but it's not as aesthetically pleasing, so I prefer this one.

An obscure bug in 5.6.0 forced me to rewrite my script for that version (the bug has been fixed for 5.6.1). Fortunately, the super spaceship operator still works.

.1 . m || <= 0, push @ tnirp => <<=>> <= print @ hsup ,0 => || m . + 1. Just another Perl hacker rekcah lreP rehto +na tsuJ ; print @ tnirp ;


Comment on Super Spaceship Operator
Select or Download Code
Re: Re: lp.hpajnilap.palinjaph.pl
by jima (Vicar) on Dec 08, 2000 at 02:26 UTC
    I stand corrected! Nice examples, there.
How the Super Spaceship works
by japhy (Canon) on Dec 08, 2000 at 02:40 UTC
    For those that do not grok this delightful Perl obfuscation, I unveil the secret of <<=>>:
    print <<=>> 1; text print "done\n"; # is actually print << "BLANK_LINE" => > 1; text BLANK_LINE print "done\n"; # is actually print << "BLANK_LINE", > 1; text BLANK_LINE print "done\n";
    And the comma is superfluous.

    japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://45627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-07-24 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (158 votes), past polls