Thank you browseruk. Wow.. I didn't realise you could sort out the whole thing using less than 2 dozen lines of perl script :O. I am so glad I asked.
However, when testing the script out with my fastq files I got three files with a few records in each, but then the script stopped and I got the following error message:
Use of uninitialized value within %outFHs in ref-to-glob cast at Sort.pl line 14, <> line 120.
Can't use string ("") as a symbol ref while "strict refs" in use at Sort.pl line 14, <> line 120.
How can I debug this? I guess this has to do with my records?