Thx tye,
when I was researching it I did wonder why I couldn't find a similar example to the code I have to deal with, but as I implied above, this area is all new to me... and the originator is long gone...sigh.
Your version makes much more sense.
If you or anyone can explain why anyone would want to store an IP address and mask in such a complex way, I'd appreciate it.
ie why (ip & mask) => 2 concat copies of the mask?
(yes, its not an accident that $str2=$str3...)

Similarly, there are 3 other examples I need to understand that look like this style:
$mask = pack ('B32', (1 x $2), (1 x (32 - $2))); $new {ISPP} {inet_aton ($1) & $mask} = + $mask . pack ('B32', (1 x 32));
ie the 2nd copy of mask is being set to 32 x 1 ?
(I intend to change the assignment of $mask to use your concat rule).
Cheers
Chris

In reply to Re: Pack/Unpack with B32 and related query by Anonymous Monk
in thread Pack/Unpack with B32 and related query by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.