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 [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 29, 2003 6:36 PM
To: [EMAIL PROTECTED]
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+hctqNgvTa7Hj2AURAoVMAKCDe0Xdv6lM+6gPTtoeBwWTScMs6gCgoIqF
cWBFKYmNl9b9P0abUI+U5nE=
=c/no
-----END PGP SIGNATURE-----
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]