You are using a C style for loop. The first element of the for loop header is an initialization statement, but $i doesn't actually do anything - it is a variable used in a silly place (void context) because the value isn't used there.
But, you'd be much better to use a Perl loop:
for my $i (0 .. 5006) { ... }
which makes what is going on much clearer. But for your particular problem you could:
#!/bin/perl use strict; use warnings; my $thing = join '', map{qw(a t c g)[rand 4]} 1 .. 5007; my $fName = "./test"; open my $outFile, '>', $fName or die "Can't create '$fName': $!\n"; print $outFile $thing; close $outFile;
Note the three parameter open, lexical file handle and a check that the open succeeded.
In reply to Re: Useless use of private variable in void context at
by GrandFather
in thread Useless use of private variable in void context at
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |