I have the following line in my Perl script:
s/\b(\w+)\b/ $replaces{$1} ? $replaces{$1} : $1 /g;
I want to find all the words in a string, and if a word in an array of known words replaces it, save it (ideally, I want to perform an arbitrary coincidence operation, not just a three-dimensional operator).
For this I am trying to use a ternary operator. Does Perl Cure? and: as an alphabetic character and simply concatenates them with variables (if they are defined).
How to get Perl to process ?: internally replace as a ternary operator?
PS: I know that I can just do the coincidence operation on the next line of code, but I want clarity to be one core for it.
source share