Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I made a hangman program...

Name: Anonymous 2008-04-27 1:15

...with perl. I am so proud.

Name: Anonymous 2008-04-27 22:42

>>1
explicit use of $_ considered harmful.

my $max_gs = shift;
push '/usr/share/dict/words' unless @ARGV;
die "Dict file \"$dict\" does not exist." unless (-e) for @ARGV;

my @words;
s/[^ &a-z-]//g and length > 8 and push @words, chomp lc while <>;
die 'No words in dict.' unless @words;

my $word = $words(rand @words);
$max_gs ||= length $word;

do {
 print "Guess: ";
 chomp ($g = lc <>);
 redo if $g !~ /^[a-z]$/ || $r_gs . $w_gs =~ /$g/;
 for ("$word\n") {
  (/$g/ ? $r_gs : $w_gs) .= $g;
  ${($r_gs, $w_gs)[!/$g/]} .= $g;
  s/[^ &$r_gs-]/_/g
  print length $w_gs, "/$max_gs\t";
  print;
  print "\nLIFE!\n" and exit if /^$word$/;
 }
} while (length $w_gw >= $max_gs);

print "\nDEATH!\n";
print "The word was $word\n";

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List