Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by runrig (Abbot)
on Nov 04, 2000 at 00:39 UTC ( [id://39903]=note: print w/replies, xml ) Need Help??


in reply to How do I compare two strings against two arrays respectively?

grep (or map) in a void context is generally considered bad. Better to store the array in a hash, especially if you access it more than once:
my %file; @routers{@ARRAY} = undef; @interfaces{@anotherarray} = undef if (exists $routers{$zero_arg} and not exists $interfaces{$sec_arg)) { #Do stuff }

Replies are listed 'Best First'.
RE: Answer: HOw do I compare two strings against to arrays respectively
by runrig (Abbot) on Nov 04, 2000 at 00:44 UTC
    Re-reading your problem (and if I understand it correctly), I'd do it this way:
    my %file; @routers{@ARRAY} = undef; die "Bad zero_arg" unless exists $routers{$zero_arg}; my %interfaces; @interfaces{@anotherarray} = undef; unless (exists $interfaces{$sec_arg)) { #Do stuff } # OR this, if appropriate return if exists $interfaces{$sec_arg}; #Do stuff

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found