I'm trying to unpack a specific problem (attached for reference). One line in particular that has me perplexed, and it leads me to two questions, one of which is perhaps a more general question about Perl itself, but if it's OK to do so I'll ask it here anyway:
$ans = SimplifyExponents($numerator,$denominator,~~@var,@expos);
From what I've been able to find, it seems that the behaviour of the smartmatch operator ~~ depends on the context. But here it seems to be applied as a unary operator to the array @var.
Based on the preceding lines, @var is guaranteed to be an array with a single scalar value, which is either "a" or "x".
I did a little playing around with perl on the command line, and tested the following code:
@array = ("a"); print(~~@array);
which yielded the output
1
But when I tried replacing the line in question with
$ans = SimplifyExponents($numerator,$denominator,1,@expos);
the expression is no longer simplified correctly. In fact, the variable seems to be dropped entirely. So this leads me to believe that when ~~@var is passed as a parameter, some other important information is passed.
Question 1: What exactly is passed to SimplifyExponents with the third parameter: ~~@var?
Question 2: Is there some place I can find the actual definition of the SimplifyExponents subroutine? It seems to be in the file "CofIdaho_macros.pl", but I cannot seem to find anything about the contents of this file.
Thanks for reading!