Matching in huge files describes a workaround that you might be able to adopt it to your purposes.
In reply to Re: split and sysread() by dws in thread split and sysread() by relaxed137