If you don't want to use a module, please advice the OP to use something that's trivially unique. No two processes can have the same process id, so instead of just hoping the combination of gettimeofday and rand is unique, just use $$. It will be unique and doesn't need your five functions to return a file name.