in reply to Letter frequencies
You'd have to ensure that you're reading plaintext, though, and not markup or something like that. The following would populate %symbol with a frequency count. You'd just pass it a list of files on the command line. What you'd do with the data from there would be up to you.
while ($line = <>) { $symbol{ $_ }++ for ( split //, $line ); }
Cheers,
Ovid
Update: mdillon had a good point. Here's a rewrite:
Or, the fun method: use my first code and add the following after the loop:while ($line = <>) { for ( split //, $line ) { $symbol{ $_ }++; $total++; } }
$total = eval (join '+', values %symbol); # :)
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Ovid) Re: Letter frequencies
by mdillon (Priest) on Nov 24, 2000 at 03:56 UTC | |
by Dominus (Parson) on Nov 24, 2000 at 04:00 UTC |