in reply to Creating A Custom Markup

In order to finish the thread, this is what I ended up using for a solution (improvments are very welcome):

code:
#!/usr/bin/perl -w

use strict;
use Template;
use File::Copy;
use File::Basename;


#------------------------------------------------------------------------
# config
#------------------------------------------------------------------------

#directory where your library files are located (files to be imported)
my $libdir   = "d:\\files\\cu\\snippits";

#directory that is to be searched (source files)
my $srcdir   = "d:\\files\\cu\\html";

#destination directory
my $destdir  = "d:\\files\\html";

#files that should be directly copied instead of processed
my @copy     = ("\.png","\.gif","\.jpg","\.cgi");

#------------------------------------------------------------------------
# end config
#------------------------------------------------------------------------

my $ttopts   = {
    RELATIVE     => 1,
    INCLUDE_PATH => [ $srcdir, $libdir ],
    OUTPUT_PATH  => $destdir,
};

my $template = Template->new($ttopts);

process_tree();

sub process_tree {
    my $dir = shift;
    my ($file, $path, $abspath, $check);
    my $target;
    local *DIR;

    my $absdir = join('/', $srcdir ? $srcdir : (), $dir ? $dir : ());
    $absdir ||= '.';

    opendir(DIR, $absdir) || do { warn "$absdir: $!\n"; return undef; };

    FILE: while (defined ($file = readdir(DIR))) {
   next if $file eq '.' || $file eq '..';
   $path = $dir ? "$dir/$file" : $file;
   $abspath = "$absdir/$file";
   
   next unless -e $abspath;

   if (-d $abspath) {
      my ($uid, $gid, $mode);

      (undef, undef, $mode, undef, $uid, $gid, undef, undef,
       undef, undef, undef, undef, undef)  = stat($abspath);

      $target = "$destdir/$path";
      mkdir $target, $mode || do { warn "mkdir  ($target): $!\n"; next; };
      
      process_tree($path);

   }
   else {
       process_file($path, $abspath);
   }
    }
    closedir(DIR);
}

sub process_file {
    my ($file, $absfile) = @_;
    my ($dest, $base, $check, $srctime, $desttime, $mode, $uid, $gid);

    $absfile ||= $file;
    $dest = $destdir ? "$destdir/$file" : $file;
    $base = basename($file);
                
    (undef, undef, $mode, undef, $uid, $gid, undef, undef, undef, $srctime,
     undef, undef, undef)  = stat($absfile);
    
    foreach $check (@copy) {
   if ($base =~ /$check/) {

      copy($absfile, $dest);
       return;
   }
    }
        $template->process($file, "", $file) || print("  ! ", $template->error(), "\n");
}


sample source file:
[% depth="../../" %]

<html>
   [% INCLUDE header title="Collectively Unconcious" %]
   [% INCLUDE open_body %]
      [% INCLUDE open_left_column %]
         [% INCLUDE site_menu %]
         [% INCLUDE cu_news %]
         [% INCLUDE search %]
      [% INCLUDE close_left_column %]
      [% INCLUDE open_middle_column %]
         [% INCLUDE who_are_we %]
            <!-- comment -->
            <table border="0" cellspacing="0" cellpadding="1" width="100%">
               <tr>
                  <td background="[% depth %]images/border.gif" bgcolor="#000000">
                     <table bgcolor="#000000" width="100%" border="0" cellspacing="0" cellpadding="2" colspan=3>
                        <tr>
                           <td bgcolor="#9C0801" align="center" valign=middle><font size="2" class="nf"><b>What are we not?</b></font></td>
                        </tr>
                        <tr height="1">
                           <td bgcolor="CC3311"></td>
                        </tr>
                        <tr>
                           <td bgcolor="#191919">
                              <b>Text goes here.<br><br>
                           </td>
                        </tr>
                     </table>
                  </td>
               </tr>
            </table><br>
            <!-- /comment-->
      [% INCLUDE close_middle_column %]
      [% INCLUDE open_right_column %]
         [% INCLUDE cu_members %]
         [% INCLUDE your_account %]
         [% INCLUDE contribute %]
         [% INCLUDE book_review %]
      [% INCLUDE close_right_column %]
   [% INCLUDE close_body %]
</html>


sample INCLUDE (header)
<head>
   <title>[% title %]</title>
   <script language="JavaScript">
      <!-- Begin popUp
         function popUp(URL) {
         day = new Date();
         id = day.getTime();
         eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=525,left = 262,top = 134');");
         }
      // End  popUp-->
   </script>
</head>