Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
An old classic, ideal to waste some time with (either playing or deobfuscating ...)

#!/usr/bin/perl use strict; use Term'ReadKey;ReadMode 'cbreak';$,=$/;$/=++$b+$b;$=='8';$b=$= x28;$*=$=x2;@!=(qw(4 _ " a 1 1 0 0 ));$![7]=`clear` ;push(@!,split shift(@!),q 7$=W8W$=8$b eq "j"8W$=8$=W8 $b eq "l"8W$=8W!8($b eq"k"&&$_!~/!/)a#W$=8#$=W8$=W#8W$=#8#!8##a\*8 $=8p$=8$=p 8$=q8q$=8p(#.{59})$=8$=$ 1q8#q(.{60 })$=8#$=$1 pap(.{60})!8$![0]++;"\*$ 1$="8q(.{6 0})!8$![0] ++;"\*$1$="8(t.*)!8$b=(l ength$1)-6 1;substr($ 1,0,$b )."!". substr($1, $b+1).$=4x "gs'"x"c"es'"c"z"gs if'.shift"z"l"just another perl hacker"l 4'SpaceInvaders'.($=x12).'domm@zsi.at j=left k=fire l=right' _'#'x58_("$*p$*"x11).$=x3_$*.("$*$*q"x11).$=_("p$*$*"x11).$= x3_($=x3).("$*$*q"x11)_1_$b.$=."W$b"_'#'x 587);j(split shift @!,pop@!);a(split shift@!,pop@!);push(@!,split shift@!,pop@! );$_=$a;map{s/\n//g}@!;map{s/v//g}@!;map{s/ //g}@!;&p;sub'j {$_=shift;$a.=m/^1/?("#$b$=$=$b#$,"x12):"#".eval( )."#$,";@_ &&j(@_)}sub'END{ReadMode 'normal' }sub'a{eval"sub'".pop().'{ eval\'s/\'.(shift).\'/\'.(shift).\'/'.pop().';@_&&'.pop().'( @_)}';@_&&a(@_)}sub'p{$b=ReadKey -1;$![1]%3==0&&x(split$=,$! [6]);z(split$=,$![4]);x(split$=,$![5]);c(split$=,$![7]);$![1 ]++;select+(@-,@-,@-,0.05);($![2]=$_)=~s/$=/ /g;/pW|Wq/&&h(' Game over');$_!~/p|q/&&h('You saved our planet. Yeah');print $![3],$![2 ];&p}sub h{print $![ 3],shift," You killed $![0] space invaders ",$,;exit}
Notes
  • If you have problems with copy&pasting the code, download it from here
  • Term::ReadKey is required, as I was to lazy to implement its functionality myself
  • There might be some problems with the refresh rate, depending on your hard/software. You could try different values, shouldn't be too hard to find in the code.
  • There are no IFs, WHILEs or FORs - as thedamian once said, control structures are for whimps!
  • In fact, most of the functions used are array manipulating stuff and regexes (and one or two (three, in fact) evals, of course)
I'll post a solution later this week...

UPDATE: Here is the solution.

--
#!/usr/bin/perl -w just another perl hacker
print+seek(DATA,$=*.3,@-)?~~<DATA>:$:__DATA__

In reply to Space Invaders by domm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-23 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found