Re: Query an IP from file Jeff Pang schreef: > I have a text file which contains lots of IPs,like: > 58.253.0.0/16; > : > 60.3.0.0/16; Is it always /16? Can they overlap? > My question is,[ ]given an IP,[ ]ie 59.32.232.33,[ ]how > can I know it exists in this file or not? exists? ITYM: matches (they are masks) You could build a byte (or nibble) oriented hash, and walk the tree. But if the masks *cannot* overlap, then put them in a sorted array, and do a binsearch, and AND the ip-nr with the nearest mask <= ip-nr. --  Affijn, Ruud "Gewoon is een tijger." --  To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org http://learn.perl.org/