The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/local/bin/perl

while (<>)
 {
  if (defined $func)
   {
    if (/__FUNCTION__/)
     {
      s/__FUNCTION__/"$func"/g;
     }
    undef $func if (/^}/);
   }
  else
   {
    $func = $1 if (/^(\w+)\s*\(/);
   }
  print;
 }