in reply to Re^2: Splitting a Blocked file in Round Robin into smaller files
in thread Splitting a Blocked file in Round Robin into smaller files
Much better explanation, thank you. Try this:
#! perl -sw use strict; my $file = $ARGV[0]; open I, '<', $file or die $!; my @outs; open $outs[ $_ ], '>', "$file.$_" or die $! for 1 .. 4; my $out = 1; while( <I> ) { print { $outs[ $out ] } $_; if( /^5/ ) { ++$out; $out = 1 if $out > 4; } }
Call it as scriptname filename. The 4 output files will be named filename.1 filename.2 filename.3 filename.4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Splitting a Blocked file in Round Robin into smaller files
by tradersjoe0 (Novice) on Dec 14, 2015 at 16:22 UTC | |
|
Re^4: Splitting a Blocked file in Round Robin into smaller files
by tradersjoe0 (Novice) on Mar 09, 2016 at 14:27 UTC | |
by BrowserUk (Patriarch) on Mar 09, 2016 at 15:12 UTC | |
by tradersjoe0 (Novice) on Mar 09, 2016 at 17:07 UTC |