I'm with Bill -- I'm not able to be certain about what you want as output (where "output" is more or less synonymous with "take out" which is -- maybe -- roughly equivalent to "capture" where the word "capture" is a hint, if you choose to read perlretut
and company, to try to answer your own (lazy) question).
Correct that guess, please, or clarify your requirements -- with a more coherent description and an example.
And please read The Perl Monks Guide to the Monastery and On asking for help & How do I post a question effectively? -- for guidance on when and how best to obtain help here.