#!/usr/bin/perl -w
use strict;

#  mktraceable
#  To take one named language subtree and add the Urchin calling code after
#  </body> so that Google-Analytics can create logs of usage etc.
#
#  Reads through each file, finds </body> and if next line DOES NOT
#  contain the beginning of the script, inserts the full tracing script.
#  If there is no </body>, just copies the file unchanged.
#
#  Version of 2007 July 18
#
sub mktraceable ;

if ($#ARGV+1 != 1) {
  die "mktraceable needs <sourcelang> as argument.\n";
  };
$dirfil = $ARGV[0];
$dirfil =~ s+/$++;  # Remove the trailing / if present
print " WILL MAKE $dirfil SUBTREE TRACEABLE.\n";
while (glob "$dirfil") {
  mktraceable ;
};
while (glob "$dirfil/*") {
  mktraceable ;
};
while (glob "$dirfil/*/*") {
  mktraceable ;
};
while (glob "$dirfil/*/*/*") {
  mktraceable ;
};
while (glob "$dirfil/*/*/*/*") {
  mktraceable ;
};
while (glob "$dirfil/*/*/*/*/*") {
  mktraceable ;
};
while (glob "$dirfil/*/*/*/*/*/*") {
  mktraceable ;
};
exit;  #End of main


sub mktraceable {

  $dirfil = $_;
  print "DIR or FILE: $dirfil\n";
};
