in reply to Regarding the conditional part of eslif (or if) statement

Thanks for your answers

I did have doubts about it being possible. I will write with several elsif statements one for each value of the array.

Thanks again monks for a speedy resolution.

  • Comment on Re: Regarding the conditional part of eslif (or if) statement

Replies are listed 'Best First'.
Re^2: Regarding the conditional part of eslif (or if) statement
by Erez (Priest) on Sep 12, 2010 at 16:23 UTC

    I will write with several elsif statements one for each value of the array

    Surely you're missing something here, why not run a foreach on the array and in that test the values, or try another thing? What you describe sounds so very un-programmatic, that I suggest reviewing the logic flow of the program at that point, and see how it could be generalised into a loop.

    "Principle of Least Astonishment: Any language that doesn’t occasionally surprise the novice will pay for it by continually surprising the expert..

Re^2: Regarding the conditional part of eslif (or if) statement
by ikegami (Patriarch) on Sep 12, 2010 at 16:29 UTC

    You've been shown a number of solutions already that make what you suggest unnecessary. There are other solutions too, if you cared to elaborate on the context.

Re^2: Regarding the conditional part of eslif (or if) statement
by AnomalousMonk (Archbishop) on Sep 13, 2010 at 22:15 UTC
    I did have doubts about it being possible.

    Of course it's possible. As several wise monks have pointed out, it's also a Very Bad (and rather pointless) Idea unless you are in contention for the Jerk of the Year award from your fellow programmers, especially those who will have to maintain your code after you 'leave' (read: 'get fired for doing stuff like this').

    But it's possible:

    >perl -wMstrict -le "my @pmis = qw(foo bar baz quux); if (do { for (@pmis) { if (/(.)\1/) { print; } } 1; }) { print q{well, that's done}; } " foo quux well, that's done