Next Tricks of the Wizards 209

Matching Many Patterns at Once

        @state_abbr = qw(AK AL AR AZ CA ... WV WY);
        @state_pat = ( 
          'Alaska',
          'Alabama',
          'Arkansas',
          'Ariz(?:\.|ona)?',
          'Cal(?:\.|if(?:\.|ornia)?)?',
          ...
          'W(?:est|\.)?\s*V(?:irginia|\.)?',
          'Wyo(?:\.|ming)?',
        );


Next Copyright © 2003 M. J. Dominus