in reply to IO::File Question
If you want to reinvent the split command again for yourself, you don't really need IO::File for that. In its most basic form, it's just a matter of opening "file.name", for input, opening "file.name.1" for output, then reading and writing a line at a time, incrementing a line counter as you go. When you've done N lines, close "file.name.1", open "file.name.2" for output, reset your line counter, and continue. When there's no more input, you're done.
update: Looking at your question again, I wonder if maybe I missed your point, but for the task you describe, it strikes me that the approach you're trying to take is ill-advised at best, because it involves loading all of a potentially large file into memory at once, and that is completely unnecessary for this task.
Perhaps you have some other reason for wanting to learn how to use IO::File, and if so, tell us about that. But don't implement file splitting this way (in the manner suggested in the OP).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: IO::File Question
by chinamox (Scribe) on Oct 23, 2006 at 04:07 UTC | |
by ikegami (Patriarch) on Oct 23, 2006 at 06:20 UTC | |
by graff (Chancellor) on Oct 23, 2006 at 05:15 UTC |