-
Notifications
You must be signed in to change notification settings - Fork 0
/
words.pl
47 lines (38 loc) · 964 Bytes
/
words.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
# Search for words in a word list
# Denis Howe 2011-05-31 - 2012-10-18 14:07
# http://foldoc.org/words.pl?tri.*bia$
use strict;
use warnings;
my $file = "words.txt";
my $google = "https://www.google.co.uk/search?q=";
# ############################################################################ #
print "Content-type: text/html\n\n";
unless (open W, $file)
{
print "Can't read $file: $!"; exit 0;
}
$_ = do { local $/; <W> };
close W;
my @w = split /\n/, $_;
my $re = $ENV{QUERY_STRING} || "";
$re =~ s/.*=//;
$re =~ s/%(..)/chr hex $1/eg;
print qq{<html><head><title>Words matching $re</title></head>
<body>
<form style="font-size: large">
<b>RE</b>
<input name="r" type="text" value="$re" style="width: 90%; font-size: large">
<input type="submit" value="Find Words" style="font-size: large">
</form><p>
};
if ($re)
{
print q{
<b>Matches:</b>
<p>
}, map("<a href=\"$google$_\">$_</a><br>\n", grep /$re/gm, @w),
q{
</body>
};
}