in reply to Re: Re: Forcing array context
in thread Forcing array context
But what is being evaluated by the regex? just the first element of the @_ array ?The regex match is doing just what is in the code - matching the first element of @_ with the regex. The effect of the list context is that whatever is matched is returned e.g
This is the result of the g modifier in list context without capturing parens. With capturing parens however it returns a list of what was captured e.gprint map("[$_]", "foo bar baz quux" =~ /b\w+ /g), $/; __output__ [bar ][baz ]
For more info regarding regex matching and context see the Regexp Quote-Like Operators section in perlop.print map("[$_]", "foo bar baz quux" =~ /(b\w+) /g), $/; __output__ [bar][baz]
_________
broquaint
|
|---|