<pre name="code" class="html"><pre name="code" class="html">自带的全局变量,默认值为“
". 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!
";
exit(-1);
};
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
while (<A>){
if (( $_ =~/$bs+$c/i ) or ($_ =~/$bs+`zjzc`.`$c`/i) ){
print $_;
};
};
插入SQL:
if ( $#ARGV < 2 ){
print "please input file update|insert table_namee!
";
exit(-1);
};
my $a=$ARGV[0];
my $b=$ARGV[1];
my $c=$ARGV[2];
local $/='/*!*/;';
open (A,"<","$a");
while (<A>){
if (( $_ =~/$bs+intos+$c/i ) or ($_ =~/$bs+intos+`zjzc`.`$c`/i) ){
print $_;
};
};