From: Mischa POSLAWSKY
Date: Mon, 30 May 2022 15:32:23 +0000 (+0200)
Subject: dieren: map table rows to array dimensions
X-Git-Tag: v1.14~82
X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/0f0737fdc23e551401deddb54465779eecdcc82b?hp=512ff6a420aa9c4ec7259a7ec937bdb5d62a2aba
dieren: map table rows to array dimensions
Just parse the text data instead of working around qw// list results.
---
diff --git a/dieren.plp b/dieren.plp
index 4332d56..4187dc8 100644
--- a/dieren.plp
+++ b/dieren.plp
@@ -78,7 +78,7 @@ say $pageinfo->{altlink};
<:
-my @table = qw(
+my @table = map {[split ' ']} grep {$_} split /\n(?!\s{3})/, q(
>: origineel: zee-: meer_water: land/aardig: anders: #:
>hond: hond zeehond scheepshond? prairiehond vleerhond #rodehond
>kat: kat zeekat meerkat cat_325? vliegende_kat #tijgerkat
@@ -107,11 +107,11 @@ my @table = qw(
#>bij: bij - waterbij aardbei moerbei hommelbij
);
if ($Request eq 'standaard') {
- $table[4 + 9*7] = 'grasmodderpaard?=è泥马'; # replace turnpaard
- $table[1 + 18*7] = 'draak_'; # irl animal
+ $table[ 9][4] = 'grasmodderpaard?=è泥马'; # replace turnpaard
+ $table[18][1] = 'draak_'; # irl animal
}
-@table = qw(
+@table = map {[split ' ']} grep {$_} split /\n/, q(
>hond zeehond prairiehond
>kat zeekat meerkat
>muis zeemuis vleermuis
@@ -141,12 +141,10 @@ if (exists $get{r}) {
}
say '';
-while (my $name = shift @table) {
+for my $row (@table) {
+for my $name (@{$row}) {
if ($name =~ s/^#// and !$pageinfo->{prefix}) {
- while ($name = shift @table) {
- last if $name =~ m/^>/;
- }
- $name or next;
+ last;
}
if ($name =~ s/^>//) {
# leading dash starts a new row
@@ -183,4 +181,5 @@ while (my $name = shift @table) {
print '';
print '';
}
+}
say '
';