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

atch has asked for the wisdom of the Perl Monks concerning the following question:

Suppose we have a tab-separated data file like this:
fruit apples fruit oranges fruit bananas meat sausages dairy eggs dairy milk meat bacon
And we have this program:
my( @fruit, @meat, @dairy ); while (<>) # input redirected appropriately { chomp; my( $category, $item ) = split /\t/; push ???$category???, $item; # what now?? }
The idea is to push the item into the array whose name is the same as the value in $category. I don't want to have an if else statement for each array.

Originally posted as a Categorized Question.