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

看板Perl作者 (阿志)時間18年前 (2006/12/27 17:07), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/2 (看更多)
請教一下,如果我有以下的文字檔: -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 這二行,但是我只想要第二行,第一行不是我要的結果, 不知各位是否知道要如何改進? 謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.77.218

12/27 17:34, , 1F
' '
12/27 17:34, 1F

12/27 23:45, , 2F
我拿你的 code 直接跑就真的只有哪一行而已呀
12/27 23:45, 2F
文章代碼(AID): #15aZVC6V (Perl)
文章代碼(AID): #15aZVC6V (Perl)