in reply to Unexepected regex match return behaviour

I think the RE is returning the $1 because it's in list context, and not scalar context. The list operator ',' [] forces it into list context. So yes, it is magic, but it's white magic. :)

Update: Corrected my (fairly terrible) mistake. Thanks for pointing this out bart.

-- Dan

Replies are listed 'Best First'.
Re: (z) Re: Is this magic?
by bart (Canon) on Jan 07, 2003 at 18:31 UTC
    The list operator ',' forces it into list context.
    That's nonsense. Haven't you ever heard of the scalar comma operator? Check out perlop, subsection "Comma operator":
    In scalar context it evaluates its left argument, throws that value away, then evaluates its right argument and returns that value.

    It's the surrounding square brackets that provide the list context.