in reply to A field comes empty
if($min == 0) { $scoring = 1; my $valid_protein = $each_protein; } elsif($min == 1) { $scoring = 0.5; } else { $scoring = 0.2; } print $fh "$fields[0], $field2, $valid_protein, $field3, $min, $scorin +g\n";
If 'the field "valid_protein"' is related to the $valid_protein lexical scalar, be aware that this scalar does not exist outside of the first if-block quoted above. The scalar $valid_protein in the statement
print $fh "$fields[0], $field2, $valid_protein, $field3, $min, $scoring\n";
has never been defined and has no value. warnings would have told you about this; strict would have prevented it.
Update: A simple fix would be to define the lexical outside the if-block, then later use it. Note, however, that this scalar is only assigned a value within the if-block, so it would be wise to initialize the scalar with some default value when it is defined:
And BTW: $scoring is never defined as a lexical anywhere; is this what you really want? (Maybe take a look at the free Modern Perl download.)my $valid_protein = 'no valid protein'; if($min == 0) { $scoring = 1; $valid_protein = $each_protein; } elsif($min == 1) { $scoring = 0.5; } else { $scoring = 0.2; } print $fh "$fields[0], $field2, $valid_protein, $field3, $min, $scorin +g\n";
Give a man a fish: <%-{-{-{-<
|
|---|