Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Weird (?) behavior with constants under special conditions

by choroba (Canon)
on Jan 31, 2013 at 14:07 UTC ( #1016323=note: print w/ replies, xml ) Need Help??


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.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Weird (?) behavior with constants under special conditions
Download Code
Re^2: Weird (?) behavior with constants under special conditions
by AnomalousMonk (Abbot) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016323]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2015-07-06 03:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls