use 5.010; my @chunks = split " ", "Debashis Pranab roy Nagendra roy murali mohan + roy"; for (1..$#chunks) { say $chunks[$_-1] if $chunks[$_] eq "roy"; }
Update: change range to start at 1, so that a leading "roy" doesn't result in the last item being printed, as pointed out by jethro++.
In reply to Re: help with regular exprestion
by moritz
in thread help with regular exprestion
by dnreddy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |