I am trying populate a text file with version information. Since the program that reads this file keys off of the #DBVersion value, every time I update the parts of the version, the next lines' #DBVersion must be changed to match what has just been changed. Here is part of the text I am trying to display:
Update aht set major = 9 #DBVersion=8.3.6 Update aht set minor = 4 #DBVersion=9.3.6 Update aht set revision = 0 #DBVersion=9.4.6
My trouble is that any part of the version could be updated so I might have to change any combination of major, minor, or revision and the corresponding numbers in the #DBVersion.
In another part of my program I initialize the $UpdatedMajor, $UpdatedMinor, etc. to "" and do a comparison between the versions and if any of the elements are different I populate $Updated with that difference. So, if for example $UpdatedMajor is populated then major has to be changed to the updated value. Here is what I have so far.
if (($UpdatedMajor != "") && ($UpdatedMinor != "") && ($UpdatedRevisio +n != "")){ printf WRITETOFILE 'Update aht set major = '."$UpdatedMajor"."\t\t\ +t".'#DBVersion='."$OldMajor.$OldMinor.$OldRevision\n"; printf WRITETOFILE 'Update aht set minor = '."$UpdatedMinor"."\t\t\ +t".'#DBVersion='."$UpdatedMajor.$OldMinor.$OldRevision\n"; printf WRITETOFILE 'Update aht set revision = '."$UpdatedRevision". +"\t\t\t".'#DBVersion='."$UpdatedMajor.$UpdatedMinor.$OldRevision\n"; + }
Right now I am thinking I will have to do 9 if's to cover all the possible scenarios. Is there any way to avoid doing this 9 times?

In reply to Trying to avoid 9 conditionals by techsan02

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.