Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Strange behaviour of tr function in case the set1 is supplied by a variable

by likbez (Sexton)
on Nov 16, 2017 at 03:10 UTC ( [id://1203547]=note: print w/replies, xml ) Need Help??


in reply to Strange behaviour of tr function in case the set1 is supplied by a variable

With eval statement works correctly. So it looks like $ is treated by tr as a regular symbol and no warning are issued.
$statement='$diff1=$str1'."=~tr/$str2//;"; eval($statement); print "With eval: diff1=$diff1\n";
that will produce:
With eval: diff1=3
</code> 
  • Comment on Re: Strange behaviour of tr function in case the set1 is supplied by a variable
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found