in reply to Strange Regex Behavior

Intriguing. If you quote the $1, you get the expected output. Quite what that tells us I'm not sure.

Update: this also works:

a => ($b =~ /(\d+)/ ? 0+$1: 0),

As does this:

a => ($b =~ /(\d+)/ ? do{ print $1; $1 }: 0),

But not this:

a => ($b =~ /(\d+)/ ? do{ $1 }: 0),

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Strange Regex Behavior
by Manchego (Acolyte) on Dec 06, 2011 at 05:58 UTC

    Interesting. Similar to your +0, this seems to work:

            a => ($b =~ /(\d+)/ ? "$1" : 0),

    Could this be a Perl bug?

      It certainly looks that way to me.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?