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

slayedbylucifer has asked for the wisdom of the Perl Monks concerning the following question:

hello Monks.

Is there a qquick and dirty way to write multiple if...elsif statement.

e.g. below block of code works fine for me, but it looks too amateurish.

foreach (@array) { if ( $_ =~ m/linux/ ) { print "This is linux VM" . "\n"; } elsif ( $_ =~ m/Windows/ ) { print "This is a Windows VM" ."\n"; } elsif ( $_ =~ m/Other/ ) { print "I have no idea what it is". "\n"; } }

Thanks for your time.