in reply to Appending data to large files

This gets you into trouble: @seperate = $i.">  <$h>\n"; You're not pushing to the array, but rather assigning to it (and thereby clearing all previous values). Use push where appropriate.

You'll also make your live easier by reading the file record by record:

local $/ = '$$$$'. "\n"; while (<DATAFILE>){ # $_ contains a record here }