http://www.perlmonks.org?node_id=1016323


in reply to Weird (?) behavior with constants under special conditions

Of course there is a way to get the result you want:
print &s/5/20/g;
As you can see, it is not wise to use operator names for constants.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Weird (?) behavior with constants under special conditions
by AnomalousMonk (Archbishop) on Jan 31, 2013 at 17:09 UTC
    ... it is not wise to use operator names for constants.

    ceo: ... or for functions, which is what constants are:

    >perl -wMstrict -le "sub tr (&$) { $_[0]->($_[1]) } sub trx (&$) { $_[0]->($_[1]) } ;; $_ = 'foo'; print 'A: ', tr{ print qq{tr match: $_[0]} }/foo/; print 'B: ', trx{ print qq{trx match: $_[0]} }/foo/; " A: 0 trx match: 1 B: 1