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 | |
by tachyon (Chancellor) on Feb 07, 2003 at 01:43 UTC | |
by Anonymous Monk on Feb 07, 2003 at 02:19 UTC | |
by tachyon (Chancellor) on Feb 08, 2003 at 10:16 UTC |