I recommend using a fast database to store your data temporarily. Mysql is perfect for this purpose, since it is very fast, and you can do very nice queries on the collected data, and you don't have to use a lot of memory in your script.
If you don't already have a DBMS installed on your system,
or if you don't want to learn DBI, you'll be able to get your code up and running quicker by using one of Perl's DBM modules.
AnyDBM_File should work on any machine that runs Perl.