in reply to Split a binary file in pieces
#!/usr/bin/perl $/ = \10_000_000; # according to IEEE, otherwise \10_485_760 open my $in, "<", $ARGV[0] or die $!; binmode $in; my $n = 1; while (<$in>) { open my $out, ">", "outfile_".$n++ or die $!; binmode $out; print $out $_; }
Update: changed <> to a manually opened <$in>, because I couldn't find a sensible way to binmode ARGV... Does anyone know how to do it?
Update-2: use open IN => ':raw'; does seem to work for <>. Or something ugly as
while (<>) { binmode(ARGV), seek(ARGV,0,0), next if $.==1; ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split a binary file in pieces
by ZJ.Mike.2009 (Scribe) on Mar 10, 2010 at 04:44 UTC | |
by Anonymous Monk on Mar 10, 2010 at 04:47 UTC | |
by ZJ.Mike.2009 (Scribe) on Mar 10, 2010 at 05:54 UTC |