DFHack/df-structures — pull request #3 by eternaleye (2014-07-10 02:17:05+00:00)
Title: First set of cleanups to Perl scripts

Here's the first set of cleanups to bring the Perl scripts more in line with current best-practices. In particular, the first patch changes over to the three-argument form of open(), while the second avoids shelling out to get the MD5 checksums of the Dwarf Fortress executable.

Still on the agenda:

- Switching from bareword filehandles to variables ( open( my $fh, ... ) instead of open( FH, ... ) )
- Using the IO::File module to make single-use patterns for files nicer (autocloses when the var goes out of scope)
- Dropping sub prototypes (see below)
- switch to the /x mode on regexes, which treats whitespace as insignificant and allows multiline regexes and comments
- possibly others as I encounter them

All of those leave the script behavior completely unchanged.

Regarding sub prototypes, the real problem with them is that "what people think they do" and "what they actually do" are very very different. Prototypes are not, for example, a viable way of enforcing a calling convention - if the sub is called as `&foo()` then prototype checking is skipped entirely. Similarly, it doesn't apply to methods at all. Further details can be found in the accepted answer of [this question](https://stackoverflow.com/questions/297034/why-are-perl-5s-function-prototypes-bad) on StackOverflow and [this essay](http://www.perlmonks.org/?node_id=861966) by Tom Christiansen.