Well, it doesn't do all the magic for you, but quite a bit:

#!/usr/bin/perl use warnings; use strict; my (@nodename, @filename, @pathname, @backupdate); use Data::Dumper; { # discard heading line my $tmp = <DATA>; } while (my $line = <DATA>){ chomp $line; my ($nn, $fn, $pn, $bd) = unpack('A8xA9xA8xA15', $line); if ($nn =~ m/\S/){ push @nodename, $nn; push @filename, $fn; push @pathname, $pn; push @backupdate, $bd; } else { $nodename[-1] .= $nn; $filename[-1] .= $fn; $pathname[-1] .= $pn; $backupdate[-1] .= $bd; } } print Dumper([\@nodename, \@filename, \@pathname, \@backupdate]); #1234567890123456789012345678901234567890123 __DATA__ NodeName FileName PathName BackupDate BD3101 bananaswi \breakfa 2007-03-06 ithapple st\fruit 14:02:31.000000 s.gif s\tree\ TP4223 chocolate \sweet\d 2006-02-28 caramelfu esserts\ 21:16:41.000000 dge.gif hersheys\ EO2123 tofuwith \organic\ 2007-07-16 peas.gif vegetable 13:55:06.000000 s\legumes\

Actually the data would better be stored in a two dimensional array.

Note that all lines that don't have the Backup Date field need to be padded with whitespaces at the end of the line to be long enough, if that's not the case you'd have to pad them manually before using unpack.


In reply to Re^3: MultiLine Tables into Variables by moritz
in thread MultiLine Tables into Variables by Knoperl

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.