http://www.perlmonks.org?node_id=7518


in reply to An Elegance Question

On the ridiculous end of the scale, why not a hash of arrays? If you're going to use your WORDS in order:
my %words = ( NOUN => [], VERB => [], ADJ => []); # use stephen's part_of_speech sub push @{ $words{$part_of_speech} }, $word;
Then, when you do your substitution: $story =~ s/[(NOUN|VERB|ADJ)]/shift @{ $words{$1} }/eg; I wouldn't do it this way, but it's food for thought.