<pre name="code" class="html"><pre name="code" class="html">自带的全局变量,默认值为“\n".  perl中”行“的概念就由$/决定

[root@zjzc01 binlog]# cat binlog.sh 
ls -ltr mysql-bin.* |  grep -v index | awk '{print $NF}' | while read A
do
echo $A
mysqlbinlog $A >$A.sql
perl binlog.pl $A.sql update SystemRole >$A.sql.txt
rm -rf $A.sql
done
[root@zjzc01 binlog]# cat binlog.pl 
if ( $#ARGV < 2 ){  
        print "please input file  update|insert table_namee!\n";  
        exit(-1);  

               }; 
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
     while (<A>){
      if  (( $_ =~/$b\s+$c/i ) or ($_ =~/$b\s+`zjzc`\.`$c`/i) ){
      print $_;
        };
      };

插入SQL:
if ( $#ARGV < 2 ){  
        print "please input file  update|insert table_namee!\n";  
        exit(-1);  


               }; 
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
     while (<A>){
      if  (( $_ =~/$b\s+into\s+$c/i ) or ($_ =~/$b\s+into\s+`zjzc`\.`$c`/i) ){
      print $_;
        };
      };