Files
basic-computer-games/31_Depth_Charge/perl/README.md
Chris Reuter d26dbf036a Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment.
This change fixes that.
2021-11-21 18:30:21 -05:00

18 lines
778 B
Markdown

Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Perl](https://www.perl.org/)
## Conversion
Not a difficult conversion - but a chance to throw in a few ways
Perl makes life easy.
* To get the sub permission which is a random location in the g x g x g grid we can use:
* assigning multiple variables in list form ($a,$b,$c) = (?,?,?)
* where the list on the right hand side is generated with a map function
* We use ternarys to generate the message if you miss the sub.
* We use join to stitch the pieces of the string together.
* If we have a ternary where we don't want to return anything we return an empty list rather than an empty string - if you return the latter you still get the padding spaces.