http://qs321.pair.com?node_id=11119328


in reply to Why is $a.$b not = "$a$b"?

Precedence

$a.($b =~ /C/)

Replies are listed 'Best First'.
Re^2: Why is $a.$b not = "$a$b"?
by tel2 (Pilgrim) on Jul 15, 2020 at 00:08 UTC
    Thank you tybalt89!

    Good answer!  Short, but good.

    To expand on that, Perl's operator precedence has '=~' higher than '.'.
    So to get the '.' notation to work as I want it to, I assume I should (parenthesise) it, like this:

    $ perl -e '$a="A";$b="B";print "Matches!\n" if ($a.$b) =~ /A/' Matches! $ perl -e '$a="A";$b="B";print "Matches!\n" if ($a.$b) =~ /C/'
    'eq' is lower than both of those, which explains why my 'eq' tests worked as I expected.

    Right?