检查enq1的partsid程序;把改行符号'='改成'=='的有关程序,check_partsid.pl
返回
# check_partsid.pl
# 检查enq1的partsid
use strict;
use DBI;
my(%t,$n,$n1,@fld,$pref,@rec,%seen);
# 连接数据库
$$pref{dsn} = "DBI:mysql:host=localhost;database=cookbook";
$$pref{dbh} = DBI->connect($$pref{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n";
$$pref{dbh}->do("SET NAMES utf8");
if(!$$pref{dbh}){
print "SQL read ERROR!\n";
exit;
}
# 取出id,partsid
$t{sth} = $$pref{dbh}->prepare("SELECT id,ourref,partsid FROM enq1");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
$t{id} = $rec[0];
@{ $t{p1s} } = split(/==/,$rec[2]);
for $n ( 0 .. $#{ $t{p1s} } ) {
@{ $t{p2s} } = split(/=/,$t{p1s}[$n]);
%seen = ();
for $n1 ( 0 .. $#{ $t{p2s} } ) {
if ( $seen{$t{p2s}[$n1]} ) {
printf ("id=%5s, ref=%7s, partsid=>",$t{id},$rec[1]);
print $rec[2],"\n";
last;
} else {
$seen{$t{p2s}[$n1]} = 1;
}
}
}
}
$t{sth}->finish;
# 关闭数据库
$$pref{dbh}->disconnect;
非常危险,有这么多!
------------------------------------------------
id=11590, ref=A102616, partsid=>1=2=3=4=5=6=7==1=2=3=4=5=6=7==7=8=9=10=11=12=13=
13=14=15=16=17=18=19=20=21=22=23=24=25=22=26==43=44=45=46=47
id=11847, ref=A111518, partsid=>286=287=177=288=238=239=289=290=291=292=293=294=
295=296=297==1=2==32=33=34=35=36=37=38=39=40=41=42=43=44=45=46=47=48=49=50=51=52
=53=54=55=56=57=58=59=60=61=62=63=64=65=66=67==2=3=4=5=6=7=8==26=27=28=29=30=31=
32=33=34=29=35=36=37==145=146=128=147=129=148=130=149=131=150=151=152=153==2==36
==72=73=74
id=11934, ref=A112213, partsid=>1=2=3=4=5=6=7=8=9=10=11=12=13=14=15=16=17=16=18=
19=20=21=22
id=12387, ref=B030803, partsid=>4=4=5=6
# pro_check.pl
# 检查·管理CGI的perl程序
use strict;
my(%t,@fld,$n);
open(IN,"pro_check.txt") or die "Can't open the file pro_check.txt\n";
while(){
chop;
if( /^file=/ ) {
@fld = split(/==>/);
push(@{ $t{files} },$fld[1]);
} elsif ( /^WORD/ ) {
@fld = split(/,/);
$t{WORD1} = $fld[1];
}
}
close(IN);
for $n ( 0 .. $#{ $t{files} } ) {
$t{file1} = $t{files}[$n];
open(IN,".\\cgi-bin\\pro\\$t{file1}") or die "Can't open the file $t{file1}.\n";
while(){
if ( $_ =~ /$t{WORD1}/ ) {
print "file=$t{file1}\n";
print "$.==>$_";
}
}
close(IN);
# exit;
}
filename=pro_check.txt
WORD,=\~ \/=\/
file=mscwrite_excel.pl
464==> if ( $t{name1} =~ /=/ ) {
1028==> if ( $t{name1} =~ /=/ ) {
1207==> if ( $t{memo} =~ /=/ ) {
1381==> if ( $t{name1} =~ /=/ ) {
------------------------------------------
WORD,=\~ s\/=\/\\\
\/g
file=mscenq1.pl
1273==> $t{name1} =~ s/=/\
/g; # 换行
file=mscenq1_parts2.pl
69==> $t{n1} =~ s/=/\
/g; #多行显示
file=mscenq1_parts3.pl
127==> $t{name1} =~ s/=/\
/g; # 多行显示
file=mscenq1_parts3.pl
263==> $t{n1} =~ s/=/\
/g; #多行显示
file=mscorder1.pl
633==> $t{name1} =~ s/=/\
/g; # 换行
file=mscqtn_input.pl
630==> $t{name1} =~ s/=/\
/g; # 换行
file=mscquo2.pl
640==> $t{name1} =~ s/=/\
/g; # 换行
file=mscquo2.pl
795==> $t{name1} =~ s/=/\
/g; # 换行
# change_equ.pl
# 把所有零件表的name的'='置换成'=='
use strict;
use DBI;
my(%t,$n,@fld,@rec,$pref);
# 连接数据库
$$pref{dsn} = "DBI:mysql:host=localhost;database=cookbook";
$$pref{dbh} = DBI->connect($$pref{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n";
$$pref{dbh}->do("SET NAMES utf8");
if(!$$pref{dbh}){
print "SQL read ERROR!\n";
exit;
}
# 取出所有表格名
@{ $t{tables} } = $$pref{dbh}->tables;
$t{all_tables} = join(' ',@{ $t{tables} });
# 取出main_type1的编号,同时生成零件表名
@{ $t{ptables} } = ();
$t{sth} = $$pref{dbh}->prepare("SELECT id FROM main_type1");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
$t{ptable1} = sprintf("%06d",$rec[0]);
$t{ptable1} = 'a' . $t{ptable1};
next unless $t{all_tables} =~ /$t{ptable1}/;
push(@{ $t{ptables} },$t{ptable1});
}
$t{sth}->finish;
# 把所有零件表的name的'='置换成'=='
for $n ( 0 .. $#{ $t{ptables} } ) {
$$pref{ptable1} = $t{ptables}[$n];
($pref) = change_ptable($pref);
}
# 关闭数据库
$$pref{dbh}->disconnect;
sub change_ptable {
my($pref) = @_;
my (%t,@rec,$aref,$row);
# 读零件表
$aref = $$pref{dbh}->selectall_arrayref("SELECT id,name from $$pref{ptable1} where name LIKE \'\%\=\%\'");
for $row ( @$aref ) {
($t{id1},$t{name1}) = @$row;
$t{name1} =~ s/=/==/g;
$t{sql} = 'UPDATE ' . $$pref{ptable1} . ' set name = "';
$t{sql} .= $t{name1} . '" where id = ';
$t{sql} .= $t{id1};
$t{DO} = $$pref{dbh}->do($t{sql});
print "ptable1=$$pref{ptable1},$t{id1}===>$t{DO}\n";
}
return($pref);
}
-----------------------------------------
enq1_ID 1671
Date 2008-10-25
OURREF 8102503
'PORTABLE TYPE WATER PROOF SPEKAER MODEL:NVS-400RB ,CAP:10W,L=15M LINE IMP : 150 OHM, JRC CODE NO: NVS-400B'
返回