in reply to if statement comparing elements of arrays?
=~ /$commands[0]/ # Matches pattern in $commands[0] =~ /\Q$commands[0]\E/ # Contains string in $commands[0] =~ /^\Q$commands[0]\E\z/ # Equals string in $commands[0] eq $commands[0] # Equals string in $commands[0]
\Q..\E is a shortcut for calling quotemeta.
And here's a solution that avoids redundancy:
if ( grep { $commands_run[$_] ne $commands[$_] } 0..$#commands ) { print "Test ---- FAIL\n"; } else { print "Test -----PASS\n"; }
|
|---|