On Fri, Dec 27, 2002 at 11:31:51AM -0500, Kipp, James wrote:
> > > I want to bitwize AND 2 IP adr strings, not sure of how to 
> > pack() them to be
> > > able to AND them. before i start playing with 
> > pack,sprintf,socket,etc.. I
> > > was wondering if someone already had a way.
> > 
> > $ perl -e 'printf "%vd\n", 192.168.1.1 & 255.255.0.0'
> > 192.168.0.0
> > 
> 
> quoting the string in anyway seems to break it. i am trying to read in the
> strings from <STDIN> like this:
> print "Enter the IP address: ";
> $ip = <STDIN>;
> print "Enter the Subnet address: ";
> $sn = <STDIN>;
> 
> printf "The network adr is: %vd\n", $ip & $sn;
> --
> output: 
> Enter the IP address: 192.168.1.1
> 192.168.1.1
> 
> Enter the Subnet address: 255.255.255.0
> 255.255.255.0
> 
> The network adr is: 48.49.48.46.48.52.48.46.48.36.49.10
> ---
> 
> how can i make this work ?

Well the quick, dirty and insecure way is

  $ip = eval <STDIN>;

If that in unsatisfactory you might want to make sure there are no
"naughty" characters in there, or you'll need an answer more along the
lines that you were looking for initially.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to