开发者

Perl pattern matching system variables

I have a pattern like this: word1 word2 word3

After pattern matching (using Perl) wi开发者_开发技巧th word1, I have to print 'word2' and 'word3' as mentioned above.

Is there any pattern system variables available to do this? If not what are the ways available to do this?

Can anyone help me.

Advance thanks Senthil.


If I understand correctly, what you have is value of word1, and you want to print two successive words after word1 has been matched?

Try this: m/$word1Pattern\s+(?<word2>\S+)\s+(?<word3>\S+)/

After that, Perl hash map called $+ should contain keys word2 and word3, and $+{word2} and $+{word3} should contain your matches.

If I understood your question in the first place, that is...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜