Hi all,
I want to print all even numbers between -100 and 100,exclusef number -12 and 98.
my problem here is I can not print it in file.
best regards,
#!/usr/bin/perl -w
print "give a file name: ";
$fname = <STDIN>;
open FH, ">$fname" or die "Cant open File $!";
# with a for loop
$i = -102;
$y = -10;
$z = 100;
while($i <=-16) {
print $i++ ,"\n";
++$i;
}
while($y <=96) {
print $y++ ,"\n";
++$y;
}
while($z <=100) {
print $z ,"\n";
++$z;
}
print FH $z++,"\n";
close FH;
exit;
I want to print all even numbers between -100 and 100,exclusef number -12 and 98.
my problem here is I can not print it in file.
best regards,
#!/usr/bin/perl -w
print "give a file name: ";
$fname = <STDIN>;
open FH, ">$fname" or die "Cant open File $!";
# with a for loop
$i = -102;
$y = -10;
$z = 100;
while($i <=-16) {
print $i++ ,"\n";
++$i;
}
while($y <=96) {
print $y++ ,"\n";
++$y;
}
while($z <=100) {
print $z ,"\n";
++$z;
}
print FH $z++,"\n";
close FH;
exit;