in reply to how to give size to a file at the time of creation
Not sure why you would want to start off with a big file but here you go, This makes a big file full of zeros. You could also use pack to get a null and fill it with those if you prefer. Or question marks as the requirement is puzzling :)
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;
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to give size to a file at the time of creation
by Tux (Canon) on May 03, 2013 at 08:00 UTC | |
by Random_Walk (Prior) on May 03, 2013 at 08:59 UTC |