in reply to Manipulating tab delimited file
The while loop will iterate through all the lines of your input file, so the foreach loop is unecessary. Also, a chomp is needed in order to avoid extraneous newlines in your output. This edited version of your code seems to work.
#!/usr/bin/env perl use strict; use warnings; my $species=$ARGV[0]; my $input=$ARGV[1]; my @fields; my $n = 0; open my $tabdata, '<', "$input" or die ("Can't open $input\n"); while (my $line = <$tabdata>) { chomp $line; my @fields = split("\t",$line); if(($fields[1] > 2) && (length($fields[0]) > 14 && length($fields[ +0]) < 31)) { print ">$species" . $n++ . "_count=$fields[1]\n$fields[0]\ +n"; } } close ($tabdata); exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Manipulating tab delimited file
by andyBio (Novice) on Apr 29, 2016 at 04:57 UTC | |
by Laurent_R (Canon) on Apr 29, 2016 at 06:25 UTC | |
by Athanasius (Archbishop) on Apr 30, 2016 at 06:11 UTC | |
|
Re^2: Manipulating tab delimited file
by andyBio (Novice) on Apr 29, 2016 at 04:39 UTC |