|
Yargo |
at Mar 29, 2003 at 5:13 pm
|
⇧ |
| |
Simple:
#!/perl
my $IP_Address = "123.456.789.000";
my $Other_IP = "123.456.789.001"; # or STDIN or whatever.
my ($A1, $B1, $C1, $D1) = (split /\./, $IP_Adress);
my ($A2, $B2, $C2, $D2) = (split /\./, $Other_IP);
if ($A1 == $A2 && $B1 == $B2 && $C1 == $C2) {
print "IP confirmed";
} else {
die "Wrong IP address\n";
}
-----Original Message-----
From: Jasmine
Sent: Saturday, March 29, 2003 6:36 PM
To: beginners@perl.org
Subject: perl help!!
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hi
i m faced with a problem.
i have a string set to an IP address and i want to be able to compare it
with
just the first three octets and see if it matches. How do i go about?
I know regex can do it but the problem is i m a newbie to it. If anyone can
figure out and explain the regex for it, it will be extremely beneficial.
thanks!
- --
Jasmine Chua
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org