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
48
49
50
51
52
53
54
|
#!/usr/bin/perl -w
# 20070807 Ashim L
# anagram finder thingy.
# Does not use a regex, due to my ineptitude.
# instead, it creates a signature for each word it scans and compares it
# with the signature of the keyword.
# surprisingly, it isn't slower than molasses in a snowstorm.
open (DICT, "wordlist"); # open dictionary file.
$totalmatches = 0;
chomp($orig_word = <STDIN>); # get and trim the original prankster (keyword)
$word = $orig_word; # so the original doesn't get pwnt (needed for debug)
# dump letters and frequency data and create signature
while ($letter = chop($word)){ $ccount{$letter}++; }
#creates a signature for the keyword
foreach $rho ( sort %ccount ) { $gamma .= $rho; }
# search loop. Searches through the whole thing until EOF.
LINE: foreach $orig_dict (<DICT>)
{
chomp($orig_dict); # get sig of dictionary word
next LINE if $orig_dict eq $orig_word;
$dict = $orig_dict; # store original word (chop fscks scalars over)
while ($char = chop($dict)){ $sighash{$char}++; }
foreach $alpha (sort %sighash){ $beta .= $alpha; }
if ( $gamma eq $beta )
# we got one!
{
print "$orig_dict\n";
$totalmatches++;
}
undef %sighash;
$beta = ''; # clear this variable. This caused headaches (for an hour)
}
# obviously some output stats.
if($totalmatches == 0) { $totalmatches = "none, hot damn." }
print "Total entries matching: $totalmatches\n";
close (DICT); # close dictionary file
exit; # weesa done annie?
|