in reply to Running out of memory while running this for loop

You really should be using a module to process CSV. Using Text::CSV for example turns your "parsing" code into:

my $csv = Text::CSV->new(); my @data = @{$csv->getline_all($in_ph)};

and as a side benefit handles commas in the data and strings with line breaks in them. Maybe your data doesn't have such wayward content, but it's sure nice to know the whole script won't fail if it does.

If your data file was huge you might want to handle it record by record instead of loading the whole lot into memory up front. Your code then becomes something like:

my $csv = Text::CSV->new(); while (my $aref = $csv->getline($in_ph)) { ... }
Premature optimization is the root of all job security