in reply to write to Disk instead of RAM without using modules
Yes, see tie and easily Tie::File and DB_File.
If you don't want to use a module, just take the code that these modules contain and use that code.