A hash seems ideal here. But since the OP is worried about space, I was going to suggest a tied hash of some kind. After looking at this thread, however, I'm more inclined to agree with roboticus and suggest that if you really have a size issue with your data, that you try putting it into a database (MySQL, Postgres, etc).