in reply to (Golf) Hangman Player
OK, it's not very short but it does the job. I'll have a go at part 2 this evening.#! /usr/bin/perl -w use strict; open WORDS,"</usr/dict/words"; my @words = (<WORDS>); close WORDS; my @guessed = qw(a b c r l); my @matches = f("__rl",\@words,\@guessed); print foreach (@matches); #-------------------------------------- sub f{ my ($guess,$wordref,$letterref) = @_; my @m = (); my $alphabet = join"|",('a'..'z'); my $guessed = join"|",@$letterref; $alphabet =~ s/$guessed//g; $guess =~ s!_![$alphabet]!g; foreach (@$wordref) { push @m,$_ if (/\b$guess\b/) } return @m; } #--------------------------------------
JJ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (Golf) Hangman Player
by dragonchild (Archbishop) on Oct 04, 2001 at 20:09 UTC | |
by japhy (Canon) on Oct 04, 2001 at 20:29 UTC |