Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Multiple check in If statement ??

by Thilosophy (Curate)
on Jul 11, 2005 at 07:52 UTC ( #473859=note: print w/ replies, xml ) Need Help??


in reply to Re: Multiple check in If statement ??
in thread Multiple check in If statement ??

Hmm, you could concat all of them, so you just need to compare two strings and thats easy.

That could also give a lot of false positives...

$a = "abcd"; $e = "e";


Comment on Re^2: Multiple check in If statement ??
Download Code
Replies are listed 'Best First'.
Re^3: Multiple check in If statement ??
by neniro (Priest) on Jul 11, 2005 at 07:55 UTC
    Yeah, you're right. Another try:
    #!/usr/bin/perl use strict; use warnings; my $a = "a"; my $b = "b"; my $c = "c"; my $d = "d"; my $e = "e"; if ( eq_list ([$a, $b, $c, $d, $e], [qw(a b c d e)]) ) { print "success\n"; } else { print "failure\n"; } sub eq_list { my ($arr1, $arr2) = @_; my @compared = map { $arr1->[$_] eq $arr2->[$_] ? 1 : 0 } (0..$#$a +rr1); my $bool = 1; $bool *= $_ for (@compared); return $bool; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2015-08-29 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (344 votes), past polls