On Mon, 25 Sep 2000, Simon Cozens wrote:
> On Mon, Sep 25, 2000 at 09:55:38AM +0100, Richard Proctor wrote:
> > While this may be a fun thing to do - why? what is the application?
>
> I think I said in the RFC, didn't I? It's extending the counting use of tr///
> to allow you to count several different letters at once. For instance, letter
> frequencies in text is an important metric for linguists, codebreakers and
> others; think about how you'd get letter frequency from a string:
>
> $as = $string =~ tr/a//;
> $bs = $string =~ tr/b//;
> $cs = $string =~ tr/c//;
> ...
> $zs = $string =~ tr/z//;
>
> Ugh.
>
> (%alphabet) = $string =~ tr/a-z//;
>
> Yum.
also a little more concise (and certainly more efficient...) than
%alphabet = map { $_ => eval "\$string =~ tr/$_//" } (a..z);
Context is beautiful; it's at least 50% of the reason I love Perl. I would
love to see it extended here.
Paris Sinclair | 4a75737420416e6f74686572
[EMAIL PROTECTED] | 205065726c204861636b6572
www.sinclairinternetwork.com