<?xml version="1.0" encoding="windows-1252"?>
<node id="989972" title="Re: Short and easy way to write if...elsif syntax" created="2012-08-27 07:57:15" updated="2012-08-27 07:57:15">
<type id="11">
note</type>
<author id="968231">
Athanasius</author>
<data>
<field name="doctext">
&lt;p&gt;For the problem &lt;i&gt;as given&lt;/i&gt;, the following simple approach may be useful:&lt;/p&gt;

&lt;code&gt;
#! perl
use strict;
use warnings;

my @array = ('Mastering linux is a steep learning curve',
             'Using Windows can be frustrating',
             'Plan 9 is rarely seen');

print /linux/   ? "This is linux VM\n"     :
      /Windows/ ? "This is a Windows VM\n" :
                  "I have no idea what it is\n" for @array;
&lt;/code&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;code&gt;
This is linux VM
This is a Windows VM
I have no idea what it is
&lt;/code&gt;

&lt;p&gt;See [doc://perlop#Conditional-Operator]. But note that this approach is not generally scalable for dealing with more complex conditions. And see the thread [id://975572] for the syntactic pitfalls.&lt;/p&gt;

&lt;p&gt;Hope that helps,&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-968231"&gt;
&lt;p&gt;Athanasius&amp;emsp;&lt;font color=#008000&gt;&amp;lt;&amp;deg;(((&amp;gt;&amp;lt;&lt;/font&gt;&amp;emsp;&lt;i&gt;contra mundum&lt;/i&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
989949</field>
<field name="parent_node">
989949</field>
</data>
</node>
