in reply to Adding an element to an array

If you're pulling data from an SQL database, the best approach may be to let the database do the work for you; SQL has a COUNT aggregate function. Something along the following lines, perhaps:

SELECT Name, COUNT(Home) AS HomeCount FROM People GROUP BY Name;

Replies are listed 'Best First'.
Re^2: Adding an element to an array
by Anonymous Monk on Oct 14, 2015 at 19:24 UTC
    Unfortunately I cant use the database for this one, since it is already too complex, I need to try using Perl.

      There are plenty of ways to unobtrusively change the statement already being used. Can you show us the SQL statement used to pull the data?