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:

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";
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.)


Give a man a fish:  <%-{-{-{-<


In reply to Re: A field comes empty by AnomalousMonk
in thread A field comes empty by pdahal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.