I'm trying to create a file of a certain size. Specifically 15MB for
some testing purposes. I want this file to have random characters. I'm
sure it would be easier (faster) to use the same character. What I'm
finding is my code is terribly slow to create a 15MB file.
Is there a better / more efficient way ?
Thanks,
Mike
#!/usr/bin/perl
use strict;
use warnings;
#PURPOSE - Create a file of a certain size (random characters)
my $file = './test.txt';
my $size = 15728640; # 15MB
open (OUT,">$file") || die "Cannot open $file :$!";
print OUT (map+chr(ord('a')+rand 26),1..$size);
close OUT;
--
Avoid the Fortran arithmetic IF (or better yet, just avoid Fortran).
00:45:04 up 3 days, 7:56, 5 users, load average: 1.92, 1.58, 0.92
Linux Registered User #241685 http://counter.li.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>