How do you print them? If there is whitespace at the start or end, they will look similar but still won't run. Also, are you sure that @commands contains regular expressions that will match? Do something like the following:
for my $i (0..$#$commands_run) { print "$i: '$commands_run[$i]' =~ /$commands[$i]/"; print $commands_run[$i] =~ /$commands[$i]/ ? ", Yes" : ", No"; print "\n"; };
That should give you a good overview.
Also, you might want to consider instead of having that long if statement using a loop similar to the one I showed for the actual testing. This will also help you to provide better diagnostic output if your test fails, as you can show which condition failed.
In reply to Re: if statement comparing elements of arrays?
by Corion
in thread if statement comparing elements of arrays?
by sqspat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |