if ( $#ARGV < 2 ){
print "please input like binglog-0001 '2013-07-01 00:00:00' '2013-07-02 00:00:00'!
";
exit(-1);
}
$file= $ARGV[0];
$start_dt = $ARGV[1];
$end_dt = $ARGV[2];
@bin=`mysqlbinlog --start-datetime='$start_dt' --stop-datetime='$end_dt' $file`;
foreach (@bin){
$_ =~ s/`//g;
#s+匹配一个或者多个空格
if ($_ =~/^updates+(.*?)s+/i)
{#print "$1 is $1
";
$act='update';
$table=$1;
$var=$act.-$table;
$hash1{$var}++;
}
if ($_ =~/^deletes+froms+(.*?)s+/i)
{#print "$1 is $1
";
$act='delete';
$table=$1;
$var=$act.-$table;
$hash2{$var}++;
}
if ($_ =~/^inserts+intos+(.*?)s+/i)
{#print "$1 is $1
";
$act='insert';
$table=$1;
$var=$act.-$table;
$hash3{$var}++;
}
};
while(my($tj, $times) = each %hash1) {
print "$tj count(*) == $times
";
};
while(my($tj, $times) = each %hash2) {
print "$tj count(*) == $times
";
};
while(my($tj, $times) = each %hash3) {
print "$tj count(*) == $times
";
};