Article 7276 of comp.lang.perl:
Xref: feenix.metronet.com comp.lang.perl:7276
Path: feenix.metronet.com!news.ecn.bgu.edu!usenet.ins.cwru.edu!agate!ames!koriel!sh.wide!wnoc-tyo-news!scslwide!wsgw!headgw!cvgw3!tshiono
From: tshiono@cv.sony.co.jp (Toru SHIONO)
Newsgroups: comp.lang.perl
Subject: Re: pack/unpack question
Message-ID: <TSHIONO.93Oct27002932@aquarius.cv.sony.co.jp>
Date: 27 Oct 93 00:29:32 GMT
References: <2ahdro$5tm@sandman.lerc.nasa.gov>
Sender: news@cv.sony.co.jp (Usenet News System)
Organization: Sony Corporation, Tokyo, Japan
Lines: 28
Nntp-Posting-Host: aquarius
X-Newsreader: prn Ver 1.07
In-reply-to: drich@lerc.nasa.gov's message of 25 Oct 93 20:44:40 GMT

In article <2ahdro$5tm@sandman.lerc.nasa.gov>
	drich@lerc.nasa.gov (Daniel Rich) writes:

:Can anyone tell me why the following code segment does not work?
:
:For the following:
:	$addr is a valid ip address (ie. 127.0.0.1)
:	$mask is a ip mask (ie. 255.255.255.255)
:	$peeraddr is the result of getpeerbyname
:
:$addr = pack("C4", (split('\.',$addr)));
:$mask = pack("C4", (split('\.',$mask)));
:if (((unpack($main'sockaddr, $peeraddr))[2] & $mask) == $addr) {
:    # Grant access
:} else {
:    # Deny access
:}

Put something like:

	vec($foo, 0, 1);

somewhere in your code to tell Perl that you want bitwise logical
operation between binary strings.

Use `eq' in place of `==' to compare binary strings.
--
Toru "devil-may-care" Shiono          Sony Corporation, JAPAN


