 <p>A short perl script that should do what you need, explained in comments:</p> <pre><code>#!/usr/bin/perl -p $ast = '*' x 75; # Number of asterisks. if (m{//=+}) { # Beginning of a comment. $inside = 1; s{.*}{/$ast\\\nDescription:}; next; } if ($inside) { unless (m{^//}) { # End of a comment. undef $inside; print '\\', $ast, "/\n" ; } s{^//}{}; # Remove the comment sign for internal lines. } </code></pre>