Hi All, brand new to perlmonks here, from few days ago and it is my first post. I came to Perl last spring (from Linux and bash scripting), really love it, learned a bit and finished some small projects, but still a begginner. My question is: Is it correct to use few if loops one after the other, as I did in this code? So, loops are not nestled and the midle if loop is with else. All that is a content of a foreach loop.

if ($char eq "a") { some code … } if ($k ==2) { some code … } else { some code … } if ($char eq "b") { some code … }

I know standard use of loops, but somehow, while trying to make my script work, I've came to this solution, that works well in my case. There is only few similar examples of using if loops such way I've found on the web, so I don't know if it is ok and maybe it is considered something to avoid or a dirty code? If it is ok, I would like to hear your comments about the whole script, but maybe that should be sent with other title. If not ok, I will begin to write the other code.


In reply to Begginer's question: If loops one after the other. Is that code correct? by predrag

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.