I have HTML files (and other files) in templates/. I have some common files in common/. After any changes, this is run:
perl mkMake.pl > Makefile make all
mkMake.pl:
$all=''; foreach $r (`/bin/ls templates/*`){ chomp($r); $r=~s/templates///; $s=''; foreach (`/bin/ls common/*`) { chomp; $s.=" $_"; } print "/11/http/website/$r: templates/$r $s\n"; print "\t /home/satyap/homepage/up2date.pl $r\n"; $all.=" /11/http/website/$r"; } print "all: $all";
#!/usr/local/bin/perl -w
$srcdir='templates'; $common='common'; $upload='/11/http/website'; $tag='SPPUpdate';
#$srcdir=location of HTML source files with special tags #$common=location of common snippets #$upload=Complete files placed here ready for upload #All paths relative to script directory. All paths do not end in / #$tag=<!-- $tag (filename) -->
$file=$ARGV[0] || '';
if($ARGV[0] eq ''){print "Argument missing\n";exit;}
print "Updating $file\n";
$file=~s/$srcdir///; chomp($file); open(I,"<$srcdir/$file") || die "$0: $srcdir/$file: $!"; open(O,">$upload/$file") || die "$0: $srcdir/$file: $!"; while(<I>) { if (/<!-- $tag/) { $_=~s/<!-- $tag\s*(\w*)\s*-->/$1/; open(SNIP,"<$common/$_") || die "$common: $!"; while(<SNIP>) {print O $_} close(SNIP); } else {print O $_} }
#EOF
Slopy, doesn't use strict, etc., but it works. yay.