in reply to Extracting each line in a file to new file seperately
If you want to learn some Perl (rather than just getting the job done — in which case you could use the split utility), the open function is the key to solve your task.
That is, read the original file line by line, and for every line, open a new file for writing, and write the line to the respective file handle. The file name would comprise a counter variable, which you increment for every line.
The orginal file can be read line by line as follows when you specify its file name on the command line:
while (my $line = <>) { # ... do something with $line }
Make an attempt yourself to fill in "...", and if you get stuck, post what you've tried so far.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extracting each line in a file to new file seperately
by nemesdani (Friar) on Feb 10, 2012 at 18:32 UTC |