I think the problem here is you haven't really laid out all the possible scenarios. Let's try doing this in English and we'll see where we get: You haven't addressed the possibility that (major_length is neither 4800 nor 8852) nor that (major_length is 8852 but val is neither 1 nor 4). Now, it may be that in your application these scenarios are impossible, but the ?: operator does not allow you to simple ignore them. You may find it easier to use an if-else construct instead:
if ($major_length == 4800) { $result = 18; } elsif ($major_length == 8552) { if ($val == 4) { $result = 33; } elsif ($val == 1) { $result = 18; } }
You still have the possibility of those unhandled situations, but now they'll simply result in $result not getting assigned at all.

In reply to Re: nested tabular ternary by Errto
in thread nested tabular ternary by bowei_99

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.