The code below is an example and a fast one, but there are essentially just two points of note:

1) fixed fields can be easily parsed with unpack.
2) printf can format your output. Just be sure to give your fields enough room.
#!/usr/bin/perl use warnings; use strict; package main; my $node_name = ""; my $host_name = ""; my $path_name = ""; my $backup_date = ""; while(<DATA>) { my ($node, $host, $path, $backup) = unpack('A9A10A10A10',$_); if ( $node =~ /^\w+/ ) { if ( $host_name =~ /\w+/ ) { printf "%-9s %-25s %-28s %-17s\n", $node_name, $host_name, $path_name, $backup_date; $node_name = ""; $host_name = ""; $path_name = ""; $backup_date = ""; } $node_name = $node; $host_name = $host; $path_name = $path; $backup_date = $backup; $backup_date =~ s/^\s+//; } else { $host_name .= $host; $path_name .= $path; $backup_date .= $backup; } } printf "%-9s %-25s %-28s %-17s\n", $node_name, $host_name, $path_name, $backup_date; __DATA__ 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\
And output is:

C:\Code>perl unpack.pl BD3101 bananaswiithapples.gif \breakfast\fruits\tree\ 2007- +14:02:31.0 TP4223 chocolatecaramelfudge.gif \sweet\desserts\hersheys\ 2006- +21:16:41.0 EO2123 tofuwithpeas.gif \organic\vegetables\legumes\ 2007- +13:55:06.0

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