Your code splits on commas but your sample data has no commas.

To produce all the networks in the format you have shown, sorted by building and VLAN, I might do something like the following:

use strict; use warnings; use Data::Dumper; do { print <<EOF; Building name $_->[8] VLAN number $_->[0] VLAN 1st Octet $_->[1] VLAN 2nd Octet $_->[2] VLAN 3rd Octet $_->[3] VLAN 4th Octet $_->[4] VLAN Subnet Slash $_->[5] VLAN Subnet Dotted $_->[6] VLAN Network $_->[7] VLAN Description $_->[9] EOF } for sort { $a->[8] cmp $b->[8] or $a->[0] <=> $b->[0] } map { [ unpack('(A3 x1)6 (A15 x1)2 A11 x1 A*') ] } <DATA>; __DATA__ 321 10 32 32 0 19 255.255.224.0 10.32.32.0 /19 Building1 Da +ta VLAN 322 10 32 0 24 255.255.255.0 10.32..0 /24 Building1 Da +ta VLAN 323 10 32 128 0 19 255.255.224.0 10.32.128.0 /19 Building1 Da +ta VLAN 324 10 32 96 0 19 255.255.224.0 10.32.96.0 /19 Building1 Da +ta VLAN 325 10 32 160 0 19 255.255.224.0 10.32.160.0 /19 Building1 Da +ta VLAN 326 10 32 192 0 19 255.255.224.0 10.32.192.0 /19 Building1 Da +ta VLAN 327 10 32 64 0 19 255.255.224.0 10.32.64.0 /19 Building1 Da +ta VLAN 328 10 32 248 0 22 255.255.252.0 10.32.248.0 /22 Building1 Da +ta VLAN 329 10 32 0 24 255.255.255.0 10.32..0 /24 Building1 Da +ta VLAN 330 10 32 224 0 24 255.255.255.0 10.32.224.0 /24 Building1 Da +ta VLAN 331 10 32 225 0 24 255.255.255.0 10.32.225.0 /24 Building2 Da +ta VLAN 332 10 32 228 0 24 255.255.255.0 10.32.228.0 /24 Building2 Da +ta VLAN 333 10 32 229 0 24 255.255.255.0 10.32.229.0 /24 Building2 Da +ta VLAN 334 10 32 232 0 24 255.255.255.0 10.32.232.0 /24 Building2 Da +ta VLAN 335 10 32 233 0 24 255.255.255.0 10.32.233.0 /24 Building2 Da +ta VLAN 336 10 32 236 0 24 255.255.255.0 10.32.236.0 /24 Building2 Da +ta VLAN 337 10 32 237 0 24 255.255.255.0 10.32.237.0 /24 Building2 Da +ta VLAN 338 10 32 240 0 24 255.255.255.0 10.32.240.0 /24 Building2 Da +ta VLAN 339 10 32 241 0 24 255.255.255.0 10.32.241.0 /24 Building2 Da +ta VLAN 340 10 32 244 0 24 255.255.255.0 10.32.244.0 /24 Building2 Da +ta VLAN 341 10 32 245 0 24 255.255.255.0 10.32.245.0 /24 Building3 Da +ta VLAN 342 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 343 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 344 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 345 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 346 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 347 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 348 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 349 10 32 0 24 255.255.255.0 10.32..0 /24 Building3 Da +ta VLAN 350 10 32 2 0 23 255.255.254.0 10.32.2.0 /23 Building3 Da +ta VLAN 351 10 32 4 0 23 255.255.254.0 10.32.4.0 /23 Building4 Da +ta VLAN 352 10 32 6 0 23 255.255.254.0 10.32.6.0 /23 Building4 Da +ta VLAN 353 10 32 8 0 23 255.255.254.0 10.32.8.0 /23 Building4 Da +ta VLAN 354 10 32 10 0 23 255.255.254.0 10.32.10.0 /23 Building4 Da +ta VLAN 355 10 32 12 0 23 255.255.254.0 10.32.12.0 /23 Building4 Da +ta VLAN 356 10 32 14 0 23 255.255.254.0 10.32.14.0 /23 Building4 Da +ta VLAN 365 10 33 32 0 24 255.255.255.0 10.33.32.0 /24 Building4 Da +ta VLAN 606 10 0 249 0 29 255.255.255.248 10.0.249.0 /29 Building4 Da +ta VLAN

But the sorting appears to be unnecessary as the data you have provided is already sorted.


In reply to Re^3: Printing of Array Hash is Missing Elements by ig
in thread Printing of Array Hash is Missing Elements by spickles

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.