http://www.perlmonks.org?node_id=989972


in reply to Short and easy way to write if...elsif syntax

For the problem as given, the following simple approach may be useful:

#! 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;

Output:

This is linux VM This is a Windows VM I have no idea what it is

See Conditional Operator. But note that this approach is not generally scalable for dealing with more complex conditions. And see the thread if statement confusion for the syntactic pitfalls.

Hope that helps,

Athanasius <°(((><contra mundum