#!/usr/bin/perl use strict; use warnings; my $file = shift; my $chunk = 2**22; # two megs my $total = -s $file; my $length = length(int($total/$chunk)); open IN, $file or die $!; { local $/ = \$chunk; my $i = 0; while () { open OUT,'>',sprintf("%0".$length."d-%s",$i++,$file); print OUT; } }