Category: | Cryptography and Text Processing |
Author/Contact Info | Will Stockwell (waldo@cyberspace.org) |
Description: | Updated as of March 16, 2001 at 0120 UTC Does frequency analysis of a monoalphabetic enciphered message via STDIN. (Thanks to Adam for the $i catch). |
#!/usr/bin/perl -w # Frequency Analyzer by Will Stockwell (waldo@cyberspace.org) # Big Willy on perlmonks.org # Thanks to japhy for the split //, lc business # Thanks to Adam for the $i catch my %letters; while (<STDIN>) { $letters{$_}++ for split //, lc; } foreach (sort keys %letters) { if($_ eq "\n") { print "\\n"; } elsif($_ eq ' ') { print "<space>"; } elsif($_ eq "\t") { print "\\t"; } else { print "$_"; } print " = $letters{$_}\n"; } |
Back to
Code Catacombs