Pulling data from a standard comment block - perl

OK so I've inherited a set of scripts that do some work on a database. They do all have a standard comment block at the beginning that has good information on the script. I would like to generate a quick web page report that lists the script name and the description lines (for now it may be expanded in the future).

For reasons that aren't worth getting into the script that is making the page has to be a perl script.

The comment block format is as follows.

# Begin-Doc
##################################################################
# Name: <script name>
# Type: Script  (recursive or script it was called by) or web page or API
#
# Description:
# <enter a description of the script here (a concise 1 line description is fine). Also 
#       include other related scripts here.>  
#
# Tables: < Tables used in the script owner.tablename >
#
# Modes: <modes or other variable that plays a major role how the script 
#                       processes and a short description of each mode
#
# Functions:  <functions and a short 1 line description of that function> 
##################################################################
# End-Doc

Now I don't have problems writing the HTML from perl, and quick my @list = `ls $search_dir`; gets me the names.

And not all parts of that block are in every file. Some don't have any Table or Mode or Function sections so I don't always have a standard place to end my parsing.

I've managed to use sed (and I admit I'm really not good with sed or many other standard *nix tools) to pull just the line with Description but if it's multi line or the description starts on the next line I'm not getting things to work right.

The snipet that is working for the single line (and yes this parses subdirectories and creates links for the scripts as I will want that for some but for now am just doing it for everything) is as follows

my @list = `ls $search_dir`;

foreach my $temp (@list) {
    chomp $temp;
    unless ($temp =~ /.+\..*/) {
        print "<a class=directory href=\"#$temp\" onclick=\"toggle('$temp');\" class=title>$temp</a><br>\n",
              "<div id=\"$temp\" style=\"display:\">\n";
        my @curdirectory = `ls $search_dir/$temp`;
        foreach my $curapplication (@curdirectory) {
            chomp $curapplication;
            print "���<a class=application href=\"https://$server/$sdir/$temp/$curapplication\" target=\"_blank\">$curapplication</a>";
            if ( my $desc_line = `sed -n '/# Description/{p;q;}' $search_dir/$temp/$curapplication` ) {
                $desc_line =~ s/^(# Description:)//i;
                print " - $desc_line<br>\n";
            }
            else { print " - No description found in header<br>\n"; }  
        }
        print "</div>\n";
    }
}

Which of course would work if the description were always a single line preceded by the # Description comment tag.

I've looked at the code at The sed (Stream Editor) FAQ - 4.21. How do I delete or change a block of text if the block contains a certain regular expression? (and other pages there0 that give examples on how to do several similar things, but my weakness with sed, grep, and regex is shining right now. I'm learning but I'd rather have this little web listing working sooner rather than later.

Anyone got some pointers for me? Yeah I'm a noob, and I have poked at some stuff on these forums but I'm still a bit stuck.

Since you are using Perl and I don't know much sed, here's some perl to extract the description.
I guess your biggest problem will be identifying where the description ends. In the following I have put that task into a subroutine so that it can be easily modified and
for starters I assume that a line with only a # on it ends the description.

foreach my $curapplication ( @curdirectory ){

  unless( open( SRC, "<$curapplication") ) {
    print "Failed to open $curapplication: $!\n";
    next;
  }

  sub description_start {
    $_[0] =~ /^\#\s*Description:/;
  }  

  sub description_end {
    $_[0] =~ /^\#\s*$/;
  }

  my $description = 0;
  while( <SRC> ){
    description_start( $_ ) and $description = 1 and next;
    if( $description ) {
      description_end( $_ ) and $description = 0 and last;
      s/^\#//;
      print;
    }
  }
}