On Fri, Dec 27, 2002 at 11:43:52AM +0530, Ramprasad wrote:

> Paul Johnson wrote:
> >On Thu, Dec 26, 2002 at 04:39:30PM -0500, Kipp, James wrote:
> >
> >>Happy Hollidays
> >>
> >>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
> >
> that is great I had used ipcalc etc for doing such a simple thing
> 
> But sir can u tell me how is "%vd" interpreted in printf

The "v" specifies that the argument is a v-string.  The "d" says to use
decimal output.  Compare:

$ perl -e 'printf "%vx\n", 192.168.1.1 & 255.255.0.0'
c0.a8.0.0
$ perl -e 'printf "%vb\n", 192.168.1.1 & 255.255.0.0'
11000000.10101000.0.0

perldoc sprintf

-- 
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