How can I get perl grep do perform regex expression capturing

perl

Solution

Probably the `map` function is a better fit for what you want. You're looking for something similar to the following (untested) code:

@substrings = map { /^test-results(.*)/ ? $1 : () } @{ $arrayref };

Problem

I'm trying to capture a substring using regex capturing with grep by getting the content of (.*) in the code below. ``` @substring = grep /^test-results(.*)/,@$(array_reference); ``` This is not working....

Original source