in reply to Formatting questions

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

Replies are listed 'Best First'.
Re: Re: Formatting questions
by Anonymous Monk on Feb 07, 2003 at 01:18 UTC
    Thanks tachyon,
    Thats exactly what I was looking for, I'll have to change some stuff, but this gives me a good foundation to start with.

    Thanks again

      Glad to help. You could use a counter to log the max hours in the munging loop (makes it easy to know the column width) and gild the lily using Spreadsheet::WriteExcel to make it really snazzy if you want to impress the PHB.

      cheers

      tachyon

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

        Do you know how to print multiple arrays in columns?
        i.e.
        @array1 = qw(one two); @array2 = qw(three four five); one three two four five
        I know it must be possible