|
|
| Think about Loose Coupling | |
| PerlMonks |
Checking for a valid IP numberby kiz (Monk) |
| on Jun 07, 2012 at 15:30 UTC ( #974973=CUFP: print w/ replies, xml ) | Need Help?? |
|
There have been a number of pages around T'internet on regexps for determining an IP number, and I needed a slight variation.... which has led me to a really natty regexp for the base use-case:
All previous examples have been long strings defining each quad separately... I use two simple tricks:
oh... and ${quad} is just a way of ensuring that the right variable name is used... a-la $foo = "${bar}barella" looks for $bar and appends barella to it In my case, I wanted to try to guess between a (partial) IP number, a hostname, or some other string (a name) - so I have:
-- Ian Stuart A man depriving some poor village, somewhere, of a first-class idiot.
Back to
Cool Uses for Perl
|
|
||||||||||||||||||||||||