in reply to How much can this text processing be optimized?
Note: You will need to add your special characters to the character class uses in the grep-block, and alter my script to read from STDIN.use strict; use warnings; my %h; while (<DATA>) { $h{$_}++ for map { lc } grep { /^[a-zA-Z]+$/ } split /\W+/; } for (sort keys %h) { printf "%10s %05d\n", $_, $h{$_}; } __DATA__ This line contains garbag3, and words! This line does not.
Update:and 00001 contains 00001 does 00001 line 00002 not 00001 this 00002 words 00001
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How much can this text processing be optimized?
by YAFZ (Pilgrim) on May 16, 2005 at 14:15 UTC |