Perl: the Markov chain saw | |
PerlMonks |
Re: How grep IP-addresses that is an exact match?by wolfi (Scribe) |
on Apr 03, 2004 at 08:07 UTC ( [id://342243]=note: print w/replies, xml ) | Need Help?? |
i believe, i've been doing an almost identical routine lately to what you've got there. When i first began, i kept getting the same results (and frustration), that you've gotten. The others touched on the key for me in their examples, but i thought, i would elaborate on what's going on. say, you have... $host = 1.2.3.4 you could get back... because perl regexes are so greedy in nature. The keys to changing this behavior for me were the addition of - these'll let perl know, you are searching for one specific expression. I use'em almost religiously now in those kinds of pattern matches. assuming that each $host(@ip_host) entry is an ip addy in the same format, i would think, that simply grepping /^$host$/ would work. either way, hope it works out for you :-)
In Section
Seekers of Perl Wisdom
|
|