The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl -i.pre
use warnings;
use strict;

# Line numbers are not maintained during the munging
while (<>) {
  $_ = '' if /^#ifndef\s+HADDOCK\s*$/ .. /^#endif\s*$/;
  s/^#(.*)/{- $1 -}/;
  print "\n\n-- #ignore-exports\n" if /^module/;
  print;
}