gio001 has asked for the wisdom of the Perl Monks concerning the following question:
perl -sple"BEGIN{open BIG};($undef,$l)=split;read(BIG,$_,$l)" -- -BIG=bigfile.dat index.dat >outfile.dat
The index file contains two columns, one for the offset and the second for a number of characters to read. The code works fine but it seems to be processing the bigfile sequentially, by this I mean it starts at 0 reads the first value in column 2 of the index file and writes out that many characters, next it continues from there and writes out the next group of x characters as identified by the next value in column 2 of the index file.How can I force a reposition of the read inside the big file by using the value in column 1 of the index file anytime a new read has to occur?
Can the logic be added to the one liner above?
Additionally how do I add a CR to each record that is going to the output file?Thanks to all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Offset Reading - two files
by BrowserUk (Patriarch) on Dec 14, 2012 at 14:13 UTC | |
by gio001 (Acolyte) on Dec 14, 2012 at 14:39 UTC | |
by BrowserUk (Patriarch) on Dec 14, 2012 at 14:50 UTC | |
by gio001 (Acolyte) on Dec 14, 2012 at 15:04 UTC | |
by BrowserUk (Patriarch) on Dec 14, 2012 at 15:10 UTC | |
| |
by gio001 (Acolyte) on Dec 14, 2012 at 15:06 UTC | |
|
Re: Offset Reading - two files
by Anonymous Monk on Dec 14, 2012 at 14:08 UTC |