in reply to Re: How to split big files with Perl ?
in thread How to split big files with Perl ?
Works pretty quickly! split almost 5gb in 4.4333 mins. I do see a decrease in performance sometimes, though other times it writes very quickly. Go ahead and test it on one of your iso's. What would be the most efficient read/write buffer?use strict; use warnings; files(); sub files { foreach (@ARGV) { print "processing $_\n"; open my $fh, '<', $_ || die "cannot open $_ $!"; binmode($fh); my $num = '000'; my $iterator = 0; split_file( $fh, $num, $_, $iterator ); } } sub split_file { my ( $fh, $num, $name, $iterator ) = @_; my $split_fh = "$name" . '.split'; open( my $out_file, '>', $split_fh . $num ) || die "cannot ope +n $split_fh$num $!"; binmode($out_file); while (1) { $iterator++; my $buf; read( $fh, $buf, 32 ); print( $out_file $buf ); my $len = length $buf; if ( $iterator == 67108864 ) { #split into 2gb chun +ks $iterator = 0; $num++; split_file( $fh, $num, $name ); } elsif ( $len !~ "32" ) { last; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to split big files with Perl ?
by RichardK (Parson) on Dec 27, 2014 at 17:20 UTC | |
by james28909 (Deacon) on Dec 28, 2014 at 03:46 UTC | |
|
Re^3: How to split big files with Perl ?
by Anonymous Monk on Dec 28, 2014 at 04:22 UTC | |
by james28909 (Deacon) on Dec 28, 2014 at 06:49 UTC | |
by Anonymous Monk on Dec 28, 2014 at 16:21 UTC |