亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1784 | 回復(fù): 5
打印 上一主題 下一主題

請教perl 引號問題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2009-10-28 16:46 |只看該作者 |倒序瀏覽
D:/perl/2.txt:

  1. x.x.x.x        uYu337i\r@06        22        aa        aa        無
  2. x.x.x.x        IM;MZ26py`9D        22        aa        aa        無
  3. x.x.x.x        4&63bA2fqp%^        22        aa        aa        無
  4. x.x.x.x        7=RLf3yBti=&        22        aa        aa        無
  5. x.x.x.x        K=^72sLX8v.J        22        aa        aa        無
  6. x.x.x.x        Qxh41P^=h4"=        22        aa        aa        無
  7. x.x.x.x        ?ba8D14jm?2f        22        aa        aa        無
復(fù)制代碼

  1. sub insert(){
  2.         open FILE,"D:/perl/2.txt" ;
  3.         while (<FILE>) {
  4.                 my ($ip,$pw,$port,$location,$business,$remark) = split ;
  5.                 print ;
  6.                 my $insert= "insert into ip_info (ip,pw,port,location,business,remark)
  7.                 values ('$ip','\Q$pw\E','$port','$location','$business','$remark')";
  8.                 $s = $dbh->prepare($insert);
  9.                 $s->execute();
  10.         }
  11.         $s->finish();
  12.         $dbh->do("commit");
  13.         close FILE ;
  14. }
復(fù)制代碼


1.執(zhí)行這個函數(shù)后,在MySQL數(shù)據(jù)庫中4&63bA2fqp%^變成4&63bA2fqp\%^
2.而如果\Q$pw\E'不加\Q.......\E的話uYu337i\r@06就會變成
  1. uYu337i
  2. @06
復(fù)制代碼


哪位大大幫幫忙了。謝謝!

論壇徽章:
1
技術(shù)圖書徽章
日期:2014-03-06 15:29:50
2 [報告]
發(fā)表于 2009-10-28 17:18 |只看該作者
quotemeta EXPR
quotemeta
Returns the value of EXPR with all non-"word" characters backslashed. (That is, all characters not matching /[A-Za-z_0-9]/ will be preceded by a backslash in the returned string, regardless of any locale settings.) This is the internal function implementing the \Q escape in double-quoted strings.

論壇徽章:
0
3 [報告]
發(fā)表于 2009-10-28 17:21 |只看該作者
$dbh->quote($string);

or

qq{$string};

論壇徽章:
0
4 [報告]
發(fā)表于 2009-10-28 17:31 |只看該作者
hi histubunnu。
用了你的方法還是有問題:
應(yīng)該是這樣使用吧?
  1. sub insert(){
  2.         open FILE,"D:/perl/2.txt" ;
  3.         while (<FILE>) {
  4.                 my ($ip,$pw,$port,$location,$business,$remark) = split ;
  5.                 print ;
  6.                 $dbh->quote($pw);
  7.                 my $insert= "insert into ip_info (ip,pw,port,location,business,remark)
  8.                 values ('$ip','\Q$pw\E','$port','$location','$business','$remark')";
  9.                 $s = $dbh->prepare($insert);
  10.                 $s->execute();
  11.         }
  12.         $s->finish();
  13.         $dbh->do("commit");
  14.         close FILE ;
  15. }
復(fù)制代碼

論壇徽章:
0
5 [報告]
發(fā)表于 2009-10-28 19:29 |只看該作者


  1. my $tmpsql = join ",",map{ $dbh -> quote($_) } ($ip,$pw,$port,$location,$business,$remark);

  2. my $sql = "insert into ip_info (ip,pw,port,location,business,remark) VALUES ($tmpsql)";
  3. $dbh->do($sql);

復(fù)制代碼

論壇徽章:
0
6 [報告]
發(fā)表于 2009-10-28 20:51 |只看該作者
非常感謝,現(xiàn)在可以啦。
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP