#!c:\perl\bin\perl.exe # use warnings; use strict; use Benchmark; my $argc = @ARGV; my $chkModified = ""; my $chk = $ARGV[0]; my $depot= $ARGV[1]; my @percentArray = (0,10,20,30,40,50,60,70,80,90,100); my $percent = 0; if($argc != 2) { die "Usage: removeDepot.pl \n"; } open(IN,"$chk") or die "Unable to open $chk: $!\n"; open(OUT,"> $chk.1.txt") or die "Unable to open diff.txt: $!\n"; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = lstat($chk); my ($total,$strSize) = 0; my $removed = 0; my $start = new Benchmark; while() { if(/\/\/$depot\//) { #print; $strSize = length($_); $total = $total + $strSize; $removed = $removed + $strSize; #print "removed: $removed"; $_ = ""; } $total = $total + length($_); $percent = int(($total/$size)*100); if(($percent % 10) == 0 && &isMember($percent,\@percentArray)) { @percentArray = grep(!/$percent/,@percentArray); printf("%.0f/%.0f %3.0f%% Removed: %.0f\n", $total,$size,$percent,$removed); } print OUT $_; } close(IN); close(OUT); my $end = new Benchmark; my $diff = timediff($end,$start); print "Time taken was ", timestr($diff, 'all'), " seconds"; sub isMember() { my $percent = shift; my $arrayRef = shift; foreach(@$arrayRef) { if($percent == $_) { return $percent; } } return 0; }