renee+2007-09-19 12:52:44--
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use strict;
use warnings;
my @values = (
['T',20,'H'],
['Hallo',3,'Welt'],
['Test',1035,'Eintrag'],
);
my $length = 6;
print sprintf "%-7s| %s |%9s\n",'col1','col2','col3';
for my $ref ( @values ){
print_formatted( $length, @$ref );
}
sub print_formatted{
my ($max,$t1,$zahl,$t2) = @_;
my ($rand) = int( ($max - length $zahl) / 2 );
my $right = $max - $rand - length $zahl;
my $format = "%-7s|%*s%s%*s|%9s\n";
print sprintf $format, $t1,$rand,' ',$zahl,$right,' ',$t2;
}
Werde mir wohl sowas bauen, wie renee es geschrieben hat.
Perl6 habe ich nicht und mit format kenne ich mich nicht aus bzw. finde es ein wenig seltsam.
Danke.
D'OH
Daniel