The point is to take a list of scrambled words from a given wordlist and then descramble them in under 30 seconds and enter them back into a form to be checked.
The problem I'm having is that for some reason it goes to the end of the list and uses the last word and returns it no matter the given input, I checked sytax and made sure that all of the curly brackets are where they're supposed to be but it still doesn't function properly.
As you will see I'm new to perl, its simlar to php so its a little easier but I still don't know all the rules =/
If you could help I'dappreciate it thanks!
#!/usr/local/bin/perl
my $filename = "/wordlist.txt";
my %wordlist;
my @curlist;
my $strid;
my $wrd;
my @inlist;
open( LIST, ") {
@curlist = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
chop;
s/\r//;
$word = $_;
foreach (split(//)) {
$curlist[ord]++;
}
$strid = join(", @curlist);
$wordlist{$strid} = $word;
# print $word . "\t" . $strid . "\n";
close(LIST);
print "word:";
while () {
chop;
@inlist = ();
foreach (split(/,/)) {
@curlist = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$wrd = $_;
foreach (split(//)) {
$curlist[ord]++;}
}
$strid = join(", @curlist);
if (exists($wordlist{$strid})) {
print $wordlist{$strid} . "\n";
push @inlist, $wordlist{$strid};
} else {
print "*** " . $wrd . ": not found\n";
push @inlist, '-';
}
}
print join(',', @inlist);
This is the error i keep getting, but when I fix it or try to it doesn't work =/
C:\Perl\bin>ana.pl
Backslash found where operator expected at C:\Perl\bin\ana.pl line 53, near "pri
nt $wordlist{$strid} . "\"
(Might be a runaway multi-line "" string starting on line 51)
(Do you need to predeclare print?)
String found where operator expected at C:\Perl\bin\ana.pl line 56, near "print
""
(Might be a runaway multi-line "" string starting on line 53)
(Missing semicolon on previous line?)
Backslash found where operator expected at C:\Perl\bin\ana.pl line 56, near "fou
nd\"
String found where operator expected at C:\Perl\bin\ana.pl line 56, at end of li
ne
(Missing semicolon on previous line?)
syntax error at C:\Perl\bin\ana.pl line 53, near "print $wordlist{$strid} . "\"
syntax error at C:\Perl\bin\ana.pl line 56, near "" . $wrd . ":"
Can't find string terminator '"' anywhere before EOF at C:\Perl\bin\ana.pl line
56.
This post has been edited by cloudnyn3: 19 August 2009 - 02:02 PM

New Topic/Question
Reply



MultiQuote





|