Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: reiterateing over array

by injunjoel (Priest)
on Aug 19, 2008 at 20:55 UTC ( #705341=note: print w/ replies, xml ) Need Help??

in reply to reiterateing over array

Another way to look at this problem is to use grep to simply see if $user[0] is in your @protected list.

open (PROTECTED, "$protected"); @protected = <PROTECTED>; close(PROTECTED); #... not sure where $tag is coming from... if (grep($_ eq $user[0], @protected)){ sock("PRIVMSG $tag:$user[0] Is A Protected User!"); }
However if you are looking for a counter of where in the list $user[0] appears you can add one to your for loop.
my $count = 0; for(@protected){ if($_ eq $user[0]){ sock(...blah blah blah...); last; } $count++; } print("$user[0] was found at ".$count+1." in the list.\n");

"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

Comment on Re: reiterateing over array
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2016-02-08 15:55 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (276 votes), past polls