Instead of reading a 'line' at a time read a 'record' at a time. Set $/ to the record separator ("-------------------------\n" in this case) and away you go:

use strict; use warnings; use Data::Dump; local $/ = "-------------------------\n"; my @records; while (<DATA>) { chomp; next unless length; push @records, [split "\n"]; } print Data::Dump::dump (\@records); __DATA__

Given the data supplied by the OP prints:

[ [ "Device ID: HS-IDF3-C3550-A.B.org", "Entry address(es):", " IP address: 10.x.x.x", "Platform: Cisco WS-C3550-12G, Capabilities: Router Switch IGMP", "Interface: GigabitEthernet3/1, Port ID (outgoing port): GigabitE +thernet0/2", "Holdtime : 158 sec", "", "Version :", "Cisco IOS Software, C3550 Software (C3550-IPSERVICES-M), Version +12.2(25)SEE, RELEASE SOFTWARE (fc2)", "Copyright (c) 1986-2006 by Cisco Systems, Inc.", "Compiled Thu 02-Feb-06 20:37 by antonino", "", "advertisement version: 2", "Protocol Hello: OUI=0x00000C, Protocol ID=0x0112; payload len=27 +, value=00000000FFFFFFFF010221FF0000000000000005313DD680FF0000", "VTP Management Domain: ''", "Duplex: full", "Management address(es):", " IP address: 10.x.x.x", ], [ "Device ID: HS-IDF3-C3550-A.B.org", "Entry address(es):", " IP address: 10.x.x.x", "Platform: Cisco WS-C3550-12G, Capabilities: Router Switch IGMP", "Interface: GigabitEthernet2/1, Port ID (outgoing port): GigabitE +thernet0/1", "Holdtime : 138 sec", "", "Version :", "Cisco IOS Software, C3550 Software (C3550-IPSERVICES-M), Version +12.2(25)SEE, RELEASE SOFTWARE (fc2)", "Copyright (c) 1986-2006 by Cisco Systems, Inc.", "Compiled Thu 02-Feb-06 20:37 by antonino", "", "advertisement version: 2", "Protocol Hello: OUI=0x00000C, Protocol ID=0x0112; payload len=27 +, value=00000000FFFFFFFF010221FF0000000000000005313DD680FF0000", "VTP Management Domain: ''", "Duplex: full", "Management address(es):", " IP address: 10.x.x.x", ], ]

True laziness is hard work

In reply to Re: Split file output into array of arrays by GrandFather
in thread Split file output into array of arrays 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.