sub in_array {

        $tst_string = shift;

        foreach ( @_ ) {

                if ($tst_string =~ m/$_/) {

                         return 1;  

                }

        }

        return 0;   

}

 

 

 

###############################

 

 

if (in_array($ip_address, @excluded)) {

            #ping

} else {

            #socket

}

 

---------------------------------

James Schappet

http://www.schappet.com

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Funk
Sent:
Monday, August 14, 2006 5:20 PM
To: perl-unix-users@listserv.ActiveState.com; perl-win32-users@listserv.ActiveState.com
Subject: [Perl-unix-users] perl grep help

 

I have a list of IP addresses that I am getting status for.  Where possible I will use a socket connection.

 

However, some of the IP addresses I need to ping.

I have a list that I need to parse through and perform a ping against.

 

The list can look like this:

 

@PINGONLY =

 

172.22.159.100

172.23.55.18

172.16.*.100

208.171.58.*

 

Does anyone have a nifty grep example I could use?

 

Code example…..

  if (grep(/^$priv_ip/, @PINGONLY)) {

     print LOG "Pinging Router: $priv_ip b/c it's in the pingonly list......\n";

     $thread  = threads->create("rtr_ping","priv","$storenum","$priv_ip")->detach;

  } else {  

     $thread  = threads->create("rtr_sock","priv","$storenum","$priv_ip")->detach;

  }  

 

If 172.16.22.100 comes up if fails the test against 172.16.*.100

 

TIA,

 

 

David M. Funk

President/CEO

 

Tivoli Certified Enterprise Consultant

Specializing in Network and Systems Management Solutions

 

Trinity Solutions          

604 Cassandra Dr.       

Cranberry Twp., PA 16066

 

Phone: 724-316-0721                   

Fax:     724-772-7889

email: [EMAIL PROTECTED]

http://www.trinitysol.net

 

        

 

 

 

_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to