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:
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.my %words = ( NOUN => [], VERB => [], ADJ => []); # use stephen's part_of_speech sub push @{ $words{$part_of_speech} }, $word;
In Section
Seekers of Perl Wisdom