in reply to Re: split file into smaller chunks
in thread split file into smaller chunks

Yes but, if I don't use >>, how will it add the record each time the counter increases?
Also, I know and I have seen many times the "die -> Can't open the file" check, but I don't really understand what's the use of it. Is there a chance the the file will not be created with the "open" function?

Replies are listed 'Best First'.
Re^3: split file into smaller chunks
by ELISHEVA (Prior) on Jul 18, 2009 at 18:38 UTC

    Concerning > vs >>. Once you open a file, records will be appended to the end of a file whether you use >> or >. The difference between the two only affects what happens to records already in the file. >> will preserve the current file contents and only add new records to the end. If you use >> and run your program a second time, the file "0-999" will have 2000 records in it. Each record from 0-999 will have two copies: the records 0-999 from the first run and then again at the end the same 1000 records repeated a second time. > avoids this problem by clearing out the old contents. It lets you start the file fresh as if it had been created for the very first time.

    Concerning die.Yes, there is a chance that the file will not be created. Here are some typical reasons:

    • You may not have permission to create files in the directory where you want to place the file.
    • The disk you want to store the file on may be full or you are using an account with a space limits and you have hit your assigned space limit.
    • Someone else is trying to create a file with the same name and the system has "locked" that file name.

    Best, beth