in reply to Wordlist maker
Instead of using s///, try tr///. It's more efficient.
Always check the return values of system calls, like open. An array in scalar context gives the number of elements.
That's untested, but that's how I'd do it. (Minus any bugs, of course.)my $file; my $out = 'wordlist.txt'; { local $/; $file = <>; } $file =~ tr/\n / /s; $file =~ tr/A-Za-z0-9 //dc; my %wordlist; $wordlist{$_}++ foreach (split ' ', $file); open(LIST, ">$out") or die "Can't open $out: $!"; print LIST join("\n", keys %wordlist); close LIST; print (scalar keys %wordlist), " words found. Saved in $out\n";
Update: Removed the problematic /d switch from the first tr/// statement, prompted by turnstep's defense of his more comprehensive post.
|
|---|