Marcus Claesson wrote:
> > lt, gt etc. are used for string comparisons. Change 'lt' to < and
> > 'gt' to > and your code should work.
> >
>
> You're right, but this script was a simplification of a
> bigger one where
> '>' didn't work (my mistake to not spot the difference...). Here is a
> more 'real' situation:
>
> Input file:
> 4635a 1e-180 BL0976
> 4635a 0 BL0978
> 4635a 1e-10 BL1343
> 4635a 8e-86 BL1774
> 4635a 6e-18 Blon1206
> 4635a 1e-123 BL1165
> 4635a 5 BL0978
> 4635a 50 BL0978
>
> Script:
>
> while (<>) {
> @row = (split /\t/);
> ($contig,$E_value,$locus_tag) = (@row);
> if ($E_value < 1e-50) {
> print "$E_value\t SMALL\n";
> } elsif (($E_value > 1e-50) && $E_value < 5) {
> print "$E_value\t BIGGER\n";
> } elsif ($_ > 5) {
This should be referencing $E_value, not $_.
> print "$E_value\t BIGGEST\n";
> }
> }
This whole thing should be simplified:
while(<>) {
my ($contig,$E_value,$locus_tag) = split;
if ($E_value < 1e-50) {
print "$E_value\t SMALL\n";
} elsif ($E_value < 5) {
print "$E_value\t BIGGER\n";
} else {
print "$E_value\t BIGGEST\n";
}
}
>
> And I then get this:
> 1e-180 SMALL
> 0 SMALL
> 1e-10 BIGGER
> 8e-86 SMALL
> 6e-18 BIGGER
> 1e-123 SMALL
> Argument "\x{34}\x{36}..." isn't numeric in numeric gt (>) at
> /home/marcus/Scripts/string2num.pl line 7, <> line 7. 5 BIGGEST
> Argument "\x{34}\x{36}..." isn't numeric in numeric gt (>) at
> /home/marcus/Scripts/string2num.pl line 7, <> line 8. 50 BIGGEST
>
> Thus, the operator isn't always correct and is not very
> accepted by perl
The operator is correct. Your program has a bug.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]