in reply to How can I use the value of a scalar as the name of an array variable?
@fruit = (); @meat = (); @dairy = (); open (FOOD, "./food.txt"); while(<FOOD>) { chomp; ($category,$item) = split(/\s+/,$_); push(@{"$category"},$item); }
Originally posted as a Categorized Answer.
|
|---|