Recently, Jeffa and I were discussing a flame by anonymous monk and I mentioned that I thought I knew the identity of the person posting....
Jeff said he thought he knew as well and asked if my guess began with an "a".
My reply was that it began with a "d" but there wasn't any point in playing hangmonk over something so trivial and thus the idea of Hangmonk came about.
The following grabs a list of the monks lurking in the Monastery and implements a game of hangman based on the name of one of the monks online at the time.
So, the next time you get flamed by anonymous monk you can play a quick game of Hangmonk to see if you can guess who it is ;-)
Special thanks go out to DrManhattan for his patient assistance and the recommendation to use map as well as to Jeffa for helping conceive the idea in the first place and also recommending I use map...you don't want to know how I was doing it before...also, to ybiC for reminding me to use -w.
Enjoy
Jeff said he thought he knew as well and asked if my guess began with an "a".
My reply was that it began with a "d" but there wasn't any point in playing hangmonk over something so trivial and thus the idea of Hangmonk came about.
The following grabs a list of the monks lurking in the Monastery and implements a game of hangman based on the name of one of the monks online at the time.
So, the next time you get flamed by anonymous monk you can play a quick game of Hangmonk to see if you can guess who it is ;-)
Special thanks go out to DrManhattan for his patient assistance and the recommendation to use map as well as to Jeffa for helping conceive the idea in the first place and also recommending I use map...you don't want to know how I was doing it before...also, to ybiC for reminding me to use -w.
Enjoy
#!/usr/bin/perl -w use strict; use XML::Simple; use LWP::UserAgent; use Games::GuessWord; my $ua = LWP::UserAgent->new(); my $response = $ua->get("http://www.perlmonks.org/index.pl?node_id=158 +51"); die $response->code() if $response->code() != 200; my $content = $response->content(); my $cblist = XMLin($content); my @user = map $_->{username}, @{$cblist->{user}}; my $monk = $user[rand @user]; my $g = Games::GuessWord->new(words => [$monk]); # Uncomment out the following for testing # print "Secret: " . $g->secret . "\n"; my @guesses = $g->guesses; do{ print "Guesses Remaining:" . $g->chances . "\n"; print "The Monk is: " . $g->answer . "\n"; print "What is your Guess?: "; my $response = <>; $g->guess($response); if ($g->won) { print "Yep, it was " . $g->secret . "...Great +Guess!\n"; exit; } }until($g->chances<=0); print "Sorry, the monk was: " . $g->secret . "\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Hangmonks
by Coruscate (Sexton) on Aug 05, 2003 at 02:19 UTC | |
by phydeauxarff (Priest) on Aug 05, 2003 at 12:10 UTC | |
Re: Hangmonks
by krisahoch (Deacon) on Aug 05, 2003 at 15:00 UTC | |
by krisahoch (Deacon) on Aug 05, 2003 at 15:11 UTC |
Back to
Cool Uses for Perl