use strict; use warnings; my $file = "test.meg"; my $mb = 1024 * 1024; my $meg = '0' x $mb; open my $fh, '>', $file or die "yuck, $file: $!\n"; print $fh $meg; seek $fh, 0, 0; # rewind to print at start. I guess you want this print $fh "I Write\n"; close $fh;