in reply to Splitting a Blocked file in Round Robin into smaller files

You use very confusing terminology, mixing "record", "line" and "block". Assuming that you consider "unit of work" boundary to be between a "block" 5 and a "block" 1, then why not simply use seek to seek to a position roughly ($file_size / $number_of_files) * $this_file and read forward until you've encountered one "block" 5? After that, the current set of "unit of work" starts.

Replies are listed 'Best First'.
Re^2: Splitting a Blocked file in Round Robin into smaller files
by tradersjoe0 (Novice) on Dec 14, 2015 at 16:08 UTC
    I am using the below code, but its not working exactly how I would like it
    #!/usr/bin/env perl use strict; use warnings; my $num_files_to_write = 4; use Data::Dumper; my @filehandles; for my $id ( 1..$num_files_to_write ) { open ( my $fh, '>', "file_$id.txt" ) or die $!; push @filehandles, $fh; } local $/ = '5'; while ( <> ) { select $filehandles[$. % $num_files_to_write]; print; } foreach my $fh ( @filehandles ) { close ( $fh ); }

      So, how does your program fail for you?