|The stupid question is the question not asked|
When is a function call not a function callby dpuu (Chaplain)
|on Mar 29, 2006 at 21:46 UTC||Need Help??|
dpuu has asked for the wisdom of the Perl Monks concerning the following question:
Everyone known why print (1+1)*2; doesn't work as newbies might expect. But there's a simple rule to understand it: if it looks like a funtion call then it is a function call.
But I came across another example today:
It appears that the sort function is seeing "uniq" as the code block that defines sort critera. OK, I thought, lets make it "look like a function call":
But nope, this still prints "0,0,1,2". To make it work I need to resort to:
or some similar intusive builtin.
This example probably just scratches the surface of some parser logic that I haven't correctly groked. Why doesn't the "if it looks like a function" rule work in this case? If a builtin like "grep" (or "map") isn't treated as a sort-criteria code block, then how do I define my own subroutines that similarly are not sort-critera?
Opinions my own; statements of fact may be in error.