Hi tomdee27,

if you were formatting your code correctly (i.e. with consistent indentation), you would probably see your mistake.

Both indentation styles shown below, used consistently, show clearly that you have a spurious extra closing curly at the end:

if ($tempdesc >= 55) { if ($tempdesc2 =~ /electric/) { print FH_OUTFILE "\n"; } else { print FH_OUTFILE "free_batteries\n"; } } else { print FH_OUTFILE "\n"; } }
And:
if ($tempdesc >= 55) { if ($tempdesc2 =~ /electric/) { print FH_OUTFILE "\n"; } else { print FH_OUTFILE "free_batteries\n"; } } else { print FH_OUTFILE "\n"; } }
Even though the compiler does not care about correct (consistent) indentation, human readers do. And that includes myself, other monks around here and, last but not least, YOU. The careless formatting of the code in your original post prevents you from seeing your error.

Taking the time to carefully and consistently indent your code (using whichever indenting style you may want to choose) is never a waste of time, and it is most of the time a great time saver. Indentation may not be needed by the compiler, but it is not optional, it is essential for the human reader (you in the first place).

You're obviously a beginner and may not have figured out this point until now, but, please, please, take right now the good habit for formatting correctly your code.


In reply to Re: If statement issue from a Noob by Laurent_R
in thread If statement issue from a Noob by tomdee27

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.