Use perl instead of GNU sed; fix spelling error

* Use Perl to replace configuration variables in place instead of GNU sed to
  help some poor souls without a proper GNU installation. This solves
  ticket:1403, thanks to sthen for the report.
* Also fix my previous spelling error: substitue vs. substitute. Again thanks to sthen :)