in reply to punctuation search (different!)
You answered your own question. A hash is a good way to go. Just translate the text in your question into code:
use strict; use warnings; my %punct = ( '?' => 'question mark', ',' => 'comma', '(' => 'open bracket', # per your terminology ); while( my ( $symbol, $descr ) = each %punct ) { print "[$symbol] = $descr\n"; }
Note the use strict; and use warnings at the top. :-)
Update: A quick search of CPAN reveals Acme::MetaSyntactic::punctuation, which may already have what you need.
|
|---|