#!/usr/bin/perl -w # # mktraceable # To take one named language subtree and add the Urchin calling code after # so that Google-Analytics can create logs of usage etc. # # Reads through each file, finds and if next line DOES NOT # contain the beginning of the script, inserts the full tracing script. # If there is no , just copies the file unchanged. # # Version of 2007 July 18 # sub mktraceable ; if ($#ARGV+1 != 1) { die "mktraceable needs as argument.\n"; }; $pub = $ARGV[0]; $pub =~ s+/$++; # Remove the trailing / if present print " WILL MAKE $pub SUBTREE TRACEABLE.\n"; opendir $DIRHANDLE, $pub; @allfiles = grep {not /^\.{1,2}\z/ } readdir $DIRHANDLE; closedir DIRHANDLE; print "@allfiles\n"; foreach $dirorfile (@allfiles) { if (-d "{$dirorfile}" ) { print "$dirorfile is a directory\n"; } elsif (-f "{$dirorfile}") { print "$dirorfile is a file\n"; }; }; exit; while (glob "$pub") { mktraceable ; }; while (glob "$pub/*") { mktraceable ; }; while (glob "$pub/*/*") { mktraceable ; }; while (glob "$pub/*/*/*") { mktraceable ; }; while (glob "$pub/*/*/*/*") { mktraceable ; }; while (glob "$pub/*/*/*/*/*") { mktraceable ; }; while (glob "$pub/*/*/*/*/*/*") { mktraceable ; }; exit; #End of main sub mktraceable { $pub = $_; print "DIR or FILE: $_\n"; print "DIR or FILE: $pub\n"; }; =oldcode #------------- if (-d $pubdirfile) { # @args = ("mkdir $pubdirfile"); print "DIR: $pubdirfile\n"; # system(@args) == 0 # or die "system @args failed; $?"; } elsif (-f $pubdirfile) { # @args = ("cat $secdirfile | sed -e 's/$sec/$pub/' > $pubdirfile"); print "FILE: $pubdirfile\n"; # system(@args) == 0 # or die "system @args failed; $?"; } else { print "NO ACT:$pubdirfile\n"; }; =cut