Re: [問題] 要怎麼抓取這些字串?

看板Perl作者 (阿志)時間18年前 (2006/12/28 16:46), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《ultra400 (阿志)》之銘言: : 請教一下,如果我有以下的文字檔: : -A inside-outside -p tcp -m tcp -s 192.168.1.68 --dport 25 -j DROP : -A inside-outside -m mac -s 192.168.1.2 --mac-source 00:0c:76:f5:7e:95 -j : ACCEPT : -A inside-outside -m mac -s 192.168.1.3 --mac-source 00:0e:2e:56:fb:f9 -j : ACCEPT : -A inside-outside -s 192.168.1.48 -j ACCEPT : 我想抓出開頭有-A inside-outside -s的那一行文字,但是我若寫成: : ……前面省略……… : while (<IN>){ : if (/-A inside-outside -s/){ : print $_; : } : } : 的話,會抓到: : -A inside-outside -p tcp -m tcp -s 192.168.1.68 --dport 25 -j DROP : -A inside-outside -s 192.168.1.48 -j ACCEPT : 這二行,但是我只想要第二行,第一行不是我要的結果, : 不知各位是否知道要如何改進? : 謝謝。 我發現是我程式的其它地方有問題啦,目前已OK了,請大家忽略這篇吧。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.72.16
文章代碼(AID): #15auHdlh (Perl)
討論串 (同標題文章)
文章代碼(AID): #15auHdlh (Perl)