For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2006 > Re: Help understanding VEC









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Help understanding VEC
Tom Phoenix

2006-03-26, 9:57 pm

On 3/26/06, Jim <jkipp5@comcast.net> wrote:

> I am trying to understand how vec() is works in the code below


Have you seen the documentation in the perlfunc manpage?

perldoc -f vec

If you still have questions, after seeing the docs, please ask again.
Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
Jim

2006-03-27, 7:57 am


>
>
> Have you seen the documentation in the perlfunc manpage?
>
> perldoc -f vec
>
> If you still have questions, after seeing the docs, please ask again.
> Hope this helps!
>


Yes, I have read it already. Thanks

John W. Krahn

2006-03-27, 6:57 pm

Jay Savage wrote:
>
> Treats the string in EXPR as a bit vector made up of elements of width
> BITS, and returns the value of the element specified by OFFSET as an
> unsigned integer.
>
> You might also want to keep in mind that the BITS must be a power of 1


It must be a power of 2.

> from one to 32, and that vec() is lvaluable, but you don't need to
> know that to look at the code here.
>
> vec( $address, 7, 1 )
>
> sayas "break up the string $address into chunks of one bit, and return
> the seventh chunk". Then it looks at the 6th chunk and the 5th chunk.


It is zero based so that is "the eighth chunk" followed by the 7th chunk and
the 6th chunk.

> The sneaky part was stringing all those tertiary "hook" operators
> together; that's probably the confusing part. John, or whoever wrote
> the code,


Guilty.

[snip]

> Why this works has to do with the way different classes of networks
> are assigned, and the way struct in_addr is defined in socket.h. For
> more information on the various standard ways hostnames and inet
> address are assigned and described, pick up a book on tcp/ip.


Or read: ftp://ftp.rfc-editor.org/in-notes/rfc1166.txt and
ftp://ftp.rfc-editor.org/in-notes/rfc1918.txt

Although classes have been mostly superseded by Classless Inter-Domain Routing
ftp://ftp.rfc-editor.org/in-notes/rfc1517.txt
ftp://ftp.rfc-editor.org/in-notes/rfc1518.txt
ftp://ftp.rfc-editor.org/in-notes/rfc1519.txt
ftp://ftp.rfc-editor.org/in-notes/rfc1520.txt



John
--
use Perl;
program
fulfillment
Chad Perrin

2006-03-27, 6:57 pm

On Mon, Mar 27, 2006 at 04:17:41PM -0800, John W. Krahn wrote:
> Jay Savage wrote:
>
> It must be a power of 2.


.. . . and thus a power of 10.

Ahem.

--
Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ]
This sig for rent: a Signify v1.14 production from http://www.debian.org/
Jim

2006-03-27, 9:57 pm


> Jay Savage wrote:
>
> power of 1
>
[color=darkred]
>
> and return
> 5th chunk.
>
[color=darkred]
>
> whoever wrote

Thanks John and Jay. It was the way the operators fell falls through. I
worked it out again and now understand it.

[color=darkred]
> socket.h. .....



I knew exactly what the goal of the code was and how class and classless
networks and subnetting works. This question was more about understanding
vec()

Thanks again



Jay Savage

2006-03-28, 3:57 am

T24gMy8yNy8wNiwgQ2hhZCBQZXJyaW4gPHBlcnJp
bkBhcG90aGVvbi5jb20+IHdyb3RlOgo+IE9u
IE1vbiwgTWFyIDI3LCAyMDA2IGF0IDA0OjE3OjQx
UE0gLTA4MDAsIEpvaG4gVy4gS3JhaG4gd3Jv
dGU6Cj4gPiBKYXkgU2F2YWdlIHdyb3RlOgo+ID4g
Pgo+ID4gPiBZb3UgbWlnaHQgYWxzbyB3YW50
IHRvIGtlZXAgaW4gbWluZCB0aGF0IHRoZSBCSVRT
IG11c3QgYmUgYSBwb3dlciBvZiAxCj4gPgo+
ID4gSXQgbXVzdCBiZSBhIHBvd2VyIG9mIDIuCj4K
PiAuIC4gLiBhbmQgdGh1cyBhIHBvd2VyIG9m
IDEwLgo+Cj4gQWhlbS4KCipncm9hbioKCkFuZCB0
aGUgd29yc3QgcGFydCBpcywgbXkgdHlwbyB3
YXMgdGhlIHNldC11cC4KCi0tIGpheQotLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLQpUaGlzIGVtYWlsIGFu
ZCBhdHRhY2htZW50KHMpOiBbICBdIGJsb2dh
YmxlOyBbIHggXSBhc2sgZmlyc3Q7IFsgIF0KcHJp
dmF0ZSBhbmQgY29uZmlkZW50aWFsCgpkYWdn
ZXJxdWlsbCBbYXRdIGdtYWlsIFtkb3RdIGNvbQpo
dHRwOi8vd3d3LnR1YXcuY29tICBodHRwOi8v
d3d3LmRwZ3VydS5jb20gIGh0dHA6Ly93d3cuZW5n
YXRpa2kub3JnCgp2YWx1ZXMgb2Yg4iB3aWxs
IGdpdmUgcmlzZSB0byBkb20hCg==
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com