求助:Perl脚本批量修改cgi文件中的语句!
时间:2011-08-23
来源:互联网
问题描述:
在一个CGI脚本 a.cgi 中,有大量的包含语句,其中一些包含select的语句,如下:
$stkn4= $dbh->prepare("select PRNR from ufh where LANG_ID =cn");
$stkn2= $dbh->prepare("select Num from knr where Num_ID =DW and KK=14");
$sth= $dbh2->prepare("select teile_string from fh02t05 where wk=1 and sj=15 and ss=12");
需要在每条完整的select语句后,加入with UR。变成如下:
$stkn4= $dbh->prepare("select PRNR from ufh where LANG_ID =cn with UR");
$stkn2= $dbh->prepare("select Num from knr where Num_ID =DW and KK=14 with UR");
$sth= $dbh2->prepare("select teile_string from fh02t05 where wk=1 and sj=15 and ss=12 with UR");
脚本中单独的select字符不用管,只对select语句起作用。
求perl正则表达式或者脚本,来批量解决这样的问题!
谢谢!
在一个CGI脚本 a.cgi 中,有大量的包含语句,其中一些包含select的语句,如下:
$stkn4= $dbh->prepare("select PRNR from ufh where LANG_ID =cn");
$stkn2= $dbh->prepare("select Num from knr where Num_ID =DW and KK=14");
$sth= $dbh2->prepare("select teile_string from fh02t05 where wk=1 and sj=15 and ss=12");
需要在每条完整的select语句后,加入with UR。变成如下:
$stkn4= $dbh->prepare("select PRNR from ufh where LANG_ID =cn with UR");
$stkn2= $dbh->prepare("select Num from knr where Num_ID =DW and KK=14 with UR");
$sth= $dbh2->prepare("select teile_string from fh02t05 where wk=1 and sj=15 and ss=12 with UR");
脚本中单独的select字符不用管,只对select语句起作用。
求perl正则表达式或者脚本,来批量解决这样的问题!
谢谢!
作者: baohuanyu 发布时间: 2011-08-23
Perl code
最简单的做法(大概这个意思,没测试过)。
修改前自己先review下替换结果。这个简单的脚本有很多特殊情况处理不了。
s/"(select.*from*)"/"\1 with UR"/g;
最简单的做法(大概这个意思,没测试过)。
修改前自己先review下替换结果。这个简单的脚本有很多特殊情况处理不了。
作者: iambic 发布时间: 2011-08-23
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28