This was working fine and i was able to get all the 8 scenarios which i was looking out for, but i felt it is not effective since i had to right 8 loops for this, i just want to know that rather than using 8 If -else looping any better effecient and effective way to do it.

Indeed in Perl there's hardly ever the need to have long sequences of if's, elsif's, etc. But it's not as much a matter of efficiency and effectiveness as much as of clumsiness: your code is hard to follow at all. So what can you do instead? One common way is a dispatch table (look it up in Super Search): that approach is very easy when you have to take an action based on which one of a given set of strings a particular one is. In this case you're having a slightly more complex situation, but at a first glance it seems to me that you can still build unique keys for a hash to use. At a further reading, I notice that all your actions amount to some print's, so the hash needs not even be one of coderefs: it's enough that values are strings. That should make for more compact and more readable code.


In reply to Re: Is there a Better work around rather than 9 If else Looping by blazar
in thread Is there a Better work around rather than 9 If else Looping by msk_0984

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.