My first reply went missing, so here it is again:
I think you need to clarify what you are trying to achieve. Perhaps by giving an example of the output you want as well as the input. You should also tidy your code, so that it is easer to read, as the indenting makes it hard to follow.
Your code also contains some strange features, such as where you read the whole line into the array @list, join it to the scalar $f and then split it again into another array @t. It makes no sense. Better still would be to read and process your file linewise as part of the foreach loop.
You need to use strict and warnings. Always and everywhere.
Another improvement would be to name the fields when your split each line instead of using array indexes, as that will make the code easier to read, and help your understanding of what you are doing. If you do that then:
my @x = split("\t",$_);Becomes:
my($index, $key, $data, @rest) = split("\t",$_);The if statements further down then become more readable. (Obviously you would need to choose your own variable names to match what you are doing. I just guessed some likely looking names.)
Modifying your code with these suggestions gives us:
#!/usr/bin/perl -w use strict; use warnings; open (FILE,"$ARGV[0]") or die; open (WRITE,">ca_0.01_1.txt"); while( my $line = <FILE> ) { my($index, $key, $data, @rest) = split("\t",$line); if(($key<=0.01) && ($index=="0")) { next if ( $data>=-8); next if ($data<-9); #next if ($index!=0); #next if ($index!=1); print WRITE ($index, $key, $data, @rest),"\n"; } } close (WRITE); close (FILE); exit;
You still need to clarify what you are doing, because it still makes no sense.
In reply to Re: Keeping one colmun fixed and second column changed at different intervals to print the output
by chrestomanci
in thread Keeping one colmun fixed and second column changed at different intervals to print the output
by vis1982
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |