http://www.perlmonks.org?node_id=139947

I had to come up with something evil yet playful for my 666th post, this is it.

I wish i could have obfuscated it, but alas. And yes, this for *NIX systems only (sorry Darwin users, deprecated confirmed that you are out to). The processes themselves are not really zombie processes - that would be...too evil. >:)

WARNING: don't run this if you don't know how to kill processes! (and don't forget about 'killall' and -9 for the occasional 'Super Zombie'!) ;)

#!/usr/bin/perl -lw use strict; # necromancer my $zombie,$|++,print $/; $SIG{TERM} = sub { hit $zombie; destroy $zombie and return unless $zombie->walks; print qq|"BRAINS!" (|,$zombie->health,' left)'; }; for (1..6) { next if fork; $zombie = raise Zombie; sleep 1 and regen $zombie while 666; } package Zombie; sub raise {print "$$ rises" and bless {hits=>int(rand 5)+2},shift} sub hit {shift->{hits}--} sub walks {shift->{hits} > 1} sub health {$_=shift->{hits};$_ > 1 ?"$_ hits":"$_ hit"} sub regen {shift->{hits}+=3 if int(rand 2)} sub destroy{print qq|"brainsss..." zombie destroyed| and exit}

P.S. deprecated tells me that some Unix systems do not have 'killall', 'pgrep', or 'pkill' handy. He recommends using this for such systems instead:

kill `ps Af | grep perl | grep -v grep | awk '{ print $2 }'`
"sometimes its ps -ef sometimes its ps -xawu and so on. solaris does have pgrep and pkill (but not before 2.6), and many of the BSD's (free open and net) will not have either so the awkkill is necessary."

Thanks deprecated! I named this script zombie.pl, so i would replace 'perl' in the line above with zombie.pl. Don't forget that you can add -9 to 'kill' in the line above as well, but that takes all the fun out! Happy Hunting! ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)