use strict; use warnings; # Already mentioned. print "\n Enter The file name :>"; chomp(my $filename1 = ); open(FILE,"<",$filename1) or die "\n...Cannot find the file: $filename1"; # Missing 1 at the end of the message. open (W, "> Result.txt"); my @line; my $count; # To be declared outside the loop to survive. while () { push (@line, $_); $count++; # Using 'my' here means $count is initialized } # to 0 in each iteration of the loop. print W $line [0]; for (my $i = 0; $i < $count; $i++) # $i was not declared { my @st = split (' ', $line [$i]); # @st was not declared if (($st [4] eq /chr1/) && ($st [10] eq /chr1/)) { print W $line [$i]; } }