in reply to if else statement check an array

Based on how I understand your question, I would do something like this.
#!/usr/bin/perl use strict; my @issued_commands = qw( ls rm df ); my @showconfig = qw( df ); my $check = @issued_commands; foreach my $issued_CM_commands (@issued_commands){ $check = (index("@showconfig", "$issued_CM_commands") > 0) ? $check : ++$check; } $check == @issued_commands ? print "Everything was in the array.\n" : print "Everything was not in the array.\n";