![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 uniojnqoifazy ![]()
![]() |
我有一個字串以,區隔,請問要怎麼切割字串,再分別將切割的字串儲存到database 原始字串: route Change,Wed Feb 5 14:19:40 2014,CIS-5426P,A Spanning Tree event for device "VLAN" at -/Gi2 on VLAN 17 in 60 seconds 切割後: str1=route Change str2=Wed Feb 5 14:19:40 2014 str3=CIS-5426P str4=A Spanning Tree event for device "VLAN" at -/Gi2 on VLAN 17 in 60 seconds Database schema: str1 varchar(30),str2 varchar(30),str3 varchar(30),str4 varchar(100) perl script 程式: [code] while (<FIFO>) { $inputline = $_; # Quit read loop when requested. last if($inputline =~ /quit/i); chop $inputline; $linenumber++; print "Got: [$inputline], "; # Insert data into table 'foo', using placeholders $dbh->do("INSERT INTO secresult VALUES (?, ?,?,?)", undef, $inputline, $inputline, $inputline, $inputline); print "inserted it.\n"; } [/code] script程式會將同一行的字串,全部儲存到DB中,請問要怎麼將字串切割,分別儲存到DB中??
本篇文章發表於2014-02-12 15:13
|