1. # we declare 8 arrays, named a to h, representing each column bottom to top i.e. @a[1] refers to the square a1 and @a[8] refers to a8.
  2. # also, we are *not* using the zero-indexed position.
  3. # the first 33 elements of each column need to " " initially
  4. my ( (@a = " " xx 33),
  5. (@b = " " xx 33),
  6. (@c = " " xx 33),
  7. (@d = " " xx 33),
  8. (@e = " " xx 33),
  9. (@f = " " xx 33),
  10. (@g = " " xx 33),
  11. (@h = " " xx 33)
  12. );
  13. #the drawing function. we draw from top row to bottom row. (while in chess the lowest row is called '1'!)
  14. # expected output:
  15. # a b c d e f g h
  16. # +---+---+---+---+---+---+---+---+
  17. # 8 | | | | | | | | | 8
  18. # +---+---+---+---+---+---+---+---+
  19. # 7 | | | | | | | | | 7
  20. # +---+---+---+---+---+---+---+---+
  21. # 6 | | | | | | | | | 6
  22. # +---+---+---+---+---+---+---+---+
  23. # 5 | | | | | | | | | 5
  24. # +---+---+---+---+---+---+---+---+
  25. # 4 | | | | | | | | | 4
  26. # +---+---+---+---+---+---+---+---+
  27. # 3 | | | | | | | | | 3
  28. # +---+---+---+---+---+---+---+---+
  29. # 2 | | | | | | | | | 2
  30. # +---+---+---+---+---+---+---+---+
  31. # 1 | | | | | | | | | 1
  32. # +---+---+---+---+---+---+---+---+
  33. # a b c d e f g h
  34. say " a b c d e f g h ";
  35. for (1..8) {
  36. say " +---+---+---+---+---+---+---+---+";
  37. say "9-$_ | @a[9-$_] | @b[9-$_] | @c[9-$_] | @d[9-$_] | @e[9-$_] | @f[9-$_] | @g[9-$_] | @h[9-$_] | 9-$_";
  38. }
  39. say " +---+---+---+---+---+---+---+---+";
  40. say " a b c d e f g h ";