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

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 ); }

Replies are listed 'Best First'.
Re^3: Splitting a Blocked file in Round Robin into smaller files
by Corion (Patriarch) on Dec 14, 2015 at 17:31 UTC

    So, how does your program fail for you?