in reply to Slow file creator

Lets see where to start. 1. first you are creating a "big ass array". you throw away th edata. No reason to do that. 2. You are opening/closing the file over and over again. You can write more than 8 bits to a file at once. Why not do something simple like...
open( ... ) for( 1 .. $choice ) { print LOG "x"; } close( ... )
3rdly, why divide choice by itself to get 1? What if the user types in 0? you dont' exit gracefully, but kill your own program.

Play that funky music white boy..

Replies are listed 'Best First'.
Re: Re: Slow file creator
by arden (Curate) on Feb 07, 2004 at 23:23 UTC
    sporty++, you've nailed it on the head! That's the way I would have done it too. To answer the anony-monk's question though, it is the opening and closing of the file that is taking so long.

    Alter your script following sporty's code snippet and your script should complete in less than a second for even a few megabytes!

    - - Arden.