dieren: map table rows to array dimensions
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 30 May 2022 15:32:23 +0000 (17:32 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 3 Jun 2022 22:53:43 +0000 (00:53 +0200)
Just parse the text data instead of working around qw// list results.

dieren.plp

index 4332d5613a58d8faa9b974e9a32231aa42d8cade..4187dc852946646a131aeba37c7cf48ef31f6659 100644 (file)
@@ -78,7 +78,7 @@ say $pageinfo->{altlink};
 </p>
 
 <:
-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 '<table class="gallery">';
-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 '</figure>';
        print '</td>';
 }
+}
 say '</tr></table>';