Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: if statement comparing elements of arrays?

by si_lence (Deacon)
on Jul 14, 2009 at 09:32 UTC ( [id://779851]=note: print w/replies, xml ) Need Help??


in reply to if statement comparing elements of arrays?

Your code works for me
use strict; use warnings; #compare the commands in the arrays my @commands_run = qw(first second third fourth fifth); my @commands = qw(first second third fourth fifth); if (($commands_run[0] =~ /$commands[0]/) &&($commands_run[1] =~ /$commands[1]/) &&($commands_run[2] =~ /$commands[2]/) &&($commands_run[3] =~ /$commands[3]/) &&($commands_run[4] =~ /$commands[4]/)) { print "Test -----PASS\n"; } else { print "Test ---- FAIL\n"; }
prints
Test -----PASS
So maybe your two arrays are not the same after all.
Maybe print them with Data::Dumper to confirm?

Cheers, si_lence

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://779851]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found