Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: if statement comparing elements of arrays?

by si_lence (Deacon)
on Jul 14, 2009 at 09:32 UTC ( #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


Comment on Re: if statement comparing elements of arrays?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2014-09-21 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (165 votes), past polls