in reply to execute loop code for every occurence of regex
If your input is: |i abc |l def |i ghi |l jkl, then the output will be: abc|jkl, which doesn't seem as the first pair to me...
The problem with your code is that * (and +) are greedy.
You can find more information about that, and how to fix it, in the perlre pod and/or perlretut pod. You can/should look for greedy and/or maximal match.
|
|---|