chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 18:41:28 +0000 (19:41 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 18:41:28 +0000 (19:41 +0100)
analyse

diff --git a/analyse b/analyse
index a9cb8f347afb279284f04fa76395c2b6b966630b..e28e1ceeb30662617d66dba97604b3be30d4dc64 100755 (executable)
--- a/analyse
+++ b/analyse
@@ -6,17 +6,17 @@ while (<>) {
   my @coords = qw(0 0 0);
   chomp;
   my $l = $_;
-  print join '', @coords;
-  while ($l =~ s/^.//) {
+  for (;;) {
+    print join '', @coords, ',';
+    last unless $l =~ s/^.//;
     $_ = $&;
     my $delta = s/[A-Z]/lc $&/e ? +1 : -1;
     my $i =
-      $& eq 'X' ? 0 :
-      $& eq 'Y' ? 1 :
-      $& eq 'Z' ? 2 :
-      die;
+      /x/ ? 0 :
+      /y/ ? 1 :
+      /z/ ? 2 :
+      die "$_ ?";
     $coords[$i] += $delta;
-    print " ", join '', @coords;
   }
   print "\n";
 }