in reply to Extra Stuff

foreach $rec (@CUSTDATA) {
I can't help but wonder why you're reading 130,000 lines of data into the array @CUSTDATA. Maybe it's not the reason why your script is crashing, but I know that my poor computer wouldn't run very well under that load.

Isn't there any way you could handle your data file one line at a time? Something like this, perhaps?

while (my $rec = <>) {

buckaduck