Here is how to chop it up into a data structure to print as you desire:

use Data::Dumper; undef $/; my $data = <DATA>; my @data = split 'HOUR\*', $data; shift @data; my (%struct, @order); for my $bit (@data) { my ($model) = $bit =~ m/MODEL\*([^:]+)/; push @order, $model; my ($hour) = $bit =~ m/^(\d\d)/; my @u = $bit =~ m/^U:([^\n]+)/mg; my @l = $bit =~ m/^L:([^\n]+)/mg; my @d = $bit =~ m/^D:([^\n]+)/mg; $struct{$model} = { hour => $hour, u => \@u, l => \@l, d => \@d }; } print Dumper \%struct; for my $model( @order ) { print "$model\n"; print 'U', "\t" x ( 1 + $struct{$model}->{hour} ), $_, "\n" for @{ +$struct{$model}->{u}}; print 'L', "\t" x ( 1 + $struct{$model}->{hour} ), $_, "\n" for @{ +$struct{$model}->{l}}; print 'D', "\t" x ( 1 + $struct{$model}->{hour} ), $_, "\n" for @{ +$struct{$model}->{d}}; } __DATA__ HOUR*00:MODEL*123.12.100.11: U:1:23 L:1:2 D:1:- HOUR*00:MODEL*123.12.100.12: U:1:86 L:1:- D:1:24 HOUR*01:MODEL*11MT-AS5300: U:8:- L:8:10 D:8:32 U:9:2 L:9:5 D:9:- HOUR*02:MODEL*132.21.001.21: U:1:6 L:1:8 D:1:2

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Formatting questions by tachyon
in thread Formatting questions by Anonymous Monk

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.