in reply to Re: Sorting A File Of Large Records
in thread Sorting A File Of Large Records

Thanks for idea #2. So I've got my {key, offset} pair nicely sorted - no problem there. I can also seek to each offset in the unsorted file without a problem. My problem is this: once I'm in the correct starting position for my next record in the unsorted file (i.e after calling seek), how can I extract *just* the next record and not the rest of the file from that point on:
for my $zip(sort{ $a <=> $b }(keys(%zips))) { seek FILE, $zips{$zip}, 0; print NEW <FILE>; }
Obviously, <FILE> contains the rest of the file following OFFSET (i.e $zips{$zip}) and not just the next record. Any ideas as to what I'm doing wrong?

Replies are listed 'Best First'.
Re: Re: Re: Sorting A File Of Large Records
by dws (Chancellor) on Dec 10, 2002 at 21:56 UTC
    My problem is this: once I'm in the correct starting position for my next record in the unsorted file (i.e after calling seek), how can I extract *just* the next record and not the rest of the file from that point on?

    Read the file line-by-line (i.e., using <FILE> in scalar context) until you've read the complete record.