views:

23

answers:

1

Hi,

I have a pattern like this:: word1 word2 word3 .

After pattern matching (using Perl) with 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.

A: 

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...

moorman