in reply to Re^2: Capturing regex from map
in thread Capturing regex from map
You are right, grep will not do captures in such a situation. I might not have been clear, but I only mentionned is as an additional useful tool in similar synctactic context, for filtering purpose.
Having said that you can do something akin to captures in a grep, although it is not very clean. Consider this:
DB<1> @a = qw (foobar barfoo foobaz, bar, foobor); DB<2> @c = grep {s/fo(ob.).+/$1/} @a; DB<3> x @c 0 'oba' 1 'oba' 2 'obo'
Not clean, I would not really recommend it, but not impossible.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Capturing regex from map
by AnomalousMonk (Archbishop) on Sep 14, 2013 at 10:30 UTC | |
by Laurent_R (Canon) on Sep 14, 2013 at 13:40 UTC |