Rather than build the hash yourself, let perl do it for you. This returns counts of punctuation but is extremely easy to modify to return other classes of characters.
Update: added \p{Symbol} to filter regex.
_____________________________________________________________use warnings; use strict; use charnames(); my %chars; while (my $line = <DATA>) { $chars{chop $line}++ while length $line; } for (keys %chars) { next unless /\p{Punct}|\p{Symbol}/; # Comment out or change this l +ine to suit my $char_count = sprintf "%25s %8s", (lc charnames::viacode(ord $_)), $chars{$_}; print "$char_count\n"; } __DATA__ Is a question that will probably seem absurd to those who are at all familiar with mineral springs or Saratoga waters. Nevertheless, it is a not unfrequent and amusing occur- rence to hear remarks from strangers and greenies who have a preconceived notion that the springs are doctored, and that a mixture of salts, etc., is tipped in every night or early in the morning! Strange that the art should be limited to the village of Saratoga! The incredulity of some people is the most ridiculous credulity known. Such wonders as the spouting springs, the "strongest" in Sara- toga, come from so small an orifice in the ground, as to preclude the least possibility of adulteration. Besides, the manufactured article would be too costly to allow such im- mense quantities to flow away unused. '{{{}}}]][[-0)(*&^^!@#$>>,<<>`~`' __END__
comma 9
quotation mark 2
less-than sign 2
greater-than sign 3
circumflex accent 2
ampersand 1
left parenthesis 1
grave accent 2
dollar sign 1
asterisk 1
tilde 1
hyphen-minus 4
full stop 5
left square bracket 2
commercial at 1
exclamation mark 3
left curly bracket 3
right square bracket 2
number sign 1
low line 4
right parenthesis 1
apostrophe 2
right curly bracket 3
In reply to Re: punctuation search (different!)
by thundergnat
in thread punctuation search (different!)
by Yoda_Oz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |