Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Answer: HOw do I compare two strings against to arrays respectively

( #39885=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > How do I compare two strings against two arrays respectively? contributed by Adam

How about something like:
sub DoubleMatch { my( $item1, $item2, $array_ref1, $array_ref2 ) = @_; for( @$array_ref1 ) { if( $_ eq $item1 ) { for my $item ( @$array_ref2 ) { return 1 if $item eq $item2 } } return 0; } } # Then you can say: if( DoubleMatch( $item1, $item2, \@array1, \@array2 ) { # do stuff }
Not that I've tested that or anything.

Comment on Answer: HOw do I compare two strings against to arrays respectively
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2014-09-19 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (138 votes), past polls