aboutsummaryrefslogtreecommitdiff
path: root/challenge-033/e-choroba/perl5/ch-2.pl
blob: b6bb51caff2e475acf96d43a23b30fa875dab954 (plain)
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
#!/usr/bin/perl
use warnings;
use strict;
use utf8;

use open OUT => ':encoding(UTF-8)', ':std';

my $MAX = shift;

my $width = 1 + length($MAX ** 2);

sub line {
    my ($header, $from) = @_;
    printf "%${width}s │", $header;
    printf "%${width}s", "" for 1 .. $from - 1;
    printf "%${width}d", $from * $_ for $from .. $MAX;
    print "\n";
}

line('×', 1);
print '─' x (1 + $width), '┼', '─' x ($width * $MAX), "\n";
for my $x (1 .. $MAX) {
    line($x, $x);
}