0: #!/usr/bin/perl -w
1: #PID Roulette - Staring Bob the Cow; by Ben Jacobs 2001
2:
3: use ExtUtils::testlib;
4: use Curses;
5:
6: srand( time() ^ ($$ + ($$ << 15)) );
7:
8: $ps = sprintf('ps -Ao "%%p %%c" |');
9: open BLAH, $ps;
10:
11: chomp(@file = <BLAH>);
12: close(BLAH);
13:
14: shift(@file);
15: $doober = @file;
16:
17: $randomnum = rand($doober);
18:
19: foreach $blah (@file) {
20: $i++;
21: ($pids[$i], $names[$i]) = $blah =~ m/\s+(\d+)\s+(\w+)/g;
22: }
23:
24: $last = @pids;
25: $randomnum = rand($last);
26:
27: print "PID Roulette\n";
28: print "Staring Bob the Cow\n";
29:
30: initscr();
31: noecho();
32: cbreak();
33:
34: $cow[0][0] = " (__)";
35: $cow[0][1] = " ______( oo";
36: $cow[0][2] = "---| \\_|";
37: $cow[0][3] = " | |";
38: $cow[0][4] = " / _______ \\";
39: $cow[0][5] = " / / \\ \\";
40:
41: $cow[2][0] = " (__)";
42: $cow[2][1] = " ______( oo";
43: $cow[2][2] = "---| \\_|";
44: $cow[2][3] = " | |";
45: $cow[2][4] = " \\ __ /";
46: $cow[2][5] = " \\ \\ / /";
47:
48: $cow[1][0] = " (__)";
49: $cow[1][1] = " ______( oo";
50: $cow[1][2] = "---| \\_|";
51: $cow[1][3] = " | |";
52: $cow[1][4] = " / ______ |";
53: $cow[1][5] = " / / / /";
54:
55: $cow[3][0] = " (__)";
56: $cow[3][1] = " ______( oo";
57: $cow[3][2] = "---| \\_|";
58: $cow[3][3] = " | |";
59: $cow[3][4] = " \\ ____ \\";
60: $cow[3][5] = " \\ \\ \\ \\";
61:
62: $cow[4][0] = "(__)";
63: $cow[4][1] = "oo )______";
64: $cow[4][2] = "|_/ |---";
65: $cow[4][3] = " | |";
66: $cow[4][4] = " | ___ |";
67: $cow[4][5] = " | | | |";
68:
69: $cow[5][0] = "(__)";
70: $cow[5][1] = "oo )______";
71: $cow[5][2] = "|_/ |---";
72: $cow[5][3] = " | |___";
73: $cow[5][4] = " | __________";
74: $cow[5][5] = " | |";
75:
76: $cow[6][0] = " | | | |";
77: $cow[6][1] = " | ---- |";
78: $cow[6][2] = " _ |";
79: $cow[6][3] = "| \\ |---";
80: $cow[6][4] = "** )------";
81: $cow[6][5] = "(--)";
82:
83: for ( $j = 0; $j < 16; $j+=2) {
84: for ( $x = 0; $x < 4; $x++) {
85: clear();
86: for ($i = 0; $i < 6; $i++) {
87: addstr($i + 2, $j, $cow[$x][$i]);
88: }
89: addstr(0, 0, "PID Roulette - Staring Bob the Cow");
90: addstr(5, 30, $pids[$randomnum]);
91: addstr(10, 0, "Bob is now going to kill \"$names[$randomnum]\", who's pid is \"$pids[$randomnum]\"");
92: refresh();
93: select(undef, undef, undef, .1);
94: }
95: }
96: select(undef, undef, undef, 1.5);
97: clear();
98: addstr(5, 30, $pids[$randomnum]);
99: for ($i = 0; $i < 6; $i++) {
100: addstr($i + 2, 16, $cow[4][$i]);
101: }
102: addstr(0, 0, "PID Roulette - Staring Bob the Cow");
103: addstr(10, 0, "Bob is now going to kill \"$names[$randomnum]\", who's pid is $pids[$randomnum]");
104: refresh();
105: select(undef, undef, undef, 1.0);
106: clear();
107: if (kill 9, $pids[$randomnum]) {
108: kill 9, $pids[$randomnum];
109: addstr(5, 30, "*POP*");
110: for ($i = 0; $i < 6; $i++) {
111: addstr($i + 2, 16, $cow[5][$i]);
112: }
113: addstr(10, 0, "mwhahahahahahaha!");
114: } else {
115: addstr(5, 30, $pids[$randomnum]);
116: for ($i = 0; $i < 6; $i++) {
117: addstr($i + 2, 16, $cow[6][$i]);
118: }
119: addstr(10, 0, "Awwwwww ... Bob couldn't kill that PID. You should be playing as root. :-(");
120: }
121: addstr(0, 0, "PID Roulette - Staring Bob the Cow");
122: refresh();
123: select(undef, undef, undef, 5);
124:
125: endwin();
126:
127: print "\nThanks for playing PID Roulette with Bob the Cow.\n\n";
-
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.