With this, I throw my code into the ring:

Update: My apologies -- I missed the part about the huge datafile. This method stores everything in memory, so that could be a problem...

#!/perl/bin/perl -w use strict; use Data::Dumper; my $spec = 'A9A10A10A15'; my $hash = {}; my $nodename = ""; my $out = {}; $_ = <DATA>; # skip the header line while (<DATA>) { #stuff everything into a hash of array refs my @arr = unpack($spec, $_); @arr = map { s/^\s+//; $_ } @arr; # remove any leading spaces if ($arr[0]) { $nodename = shift(@arr); } else { shift(@arr); } push(@{$hash->{$nodename}}, \@arr); } print Dumper($hash); # contents may be viewed in $VAR1 below for my $key (keys %$hash) { my $rows = $hash->{$key}; for (my $rownum = 0; $rownum <= $#$rows; $rownum++) { my $cols = $rows->[$rownum]; for (my $col = 0; $col <= $#$cols; $col++) { # include a space between the date/time strings my $space = ($rownum == 0 && $col == 2) ? ' ' : ''; $out->{$key}->[$col] .= $cols->[$col] . $space; } } } for my $key (keys %$out) { printf "%-7s %-25s %-29s %-30s\n", $key, @{$out->{$key}}; } __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\ __OUTPUT__ $VAR1 = { 'TP4223' => [ [ 'chocolate', '\\sweet\\d', '2006-02-28' ], [ 'caramelfu', 'esserts\\', '21:16:41.000000' ], [ 'dge.gif', 'hersheys\\', '' ] ], 'BD3101' => [ [ 'bananaswi', '\\breakfa', '2007-03-06' ], ... etc ... TP4223 chocolatecaramelfudge.gif \sweet\desserts\hersheys\ 2006-0 +2-28 21:16:41.000000 BD3101 bananaswiithapples.gif \breakfast\fruits\tree\ 2007-0 +3-06 14:02:31.000000 EO2123 tofuwithpeas.gif \organic\vegetables\legumes\ 2007-0 +7-16 13:55:06.000000

Where do you want *them* to go today?

In reply to Re: MultiLine Tables into Variables by thezip
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.