I have some code that uses Term::ReadKey to get some user input, but 99 times out of 100 when this script is run, it picks the data up from a file instead, and Term::Readkey isn't needed. So I figure why not do away with the dependency, and require Term::ReadKey in when needed.
But the sub that uses it contains a couple of statements like this:
ReadMode 1; # some stuff ReadMode 2;
Intrigued by this - apparently a function call without parentheses - I asked in the CB, and was told that the parentheses are optional for a single param function call. But this test case:
testcall 1; testcall(2); sub testcall { print $_[0]; print "\n"; }
fails to compile with:
Number found where operator expected at fcall.pl line 1, near "testcal +l 1" (Do you need to predeclare testcall?) syntax error at fcall.pl line 1, near "testcall 1" Execution of fcall.pl aborted due to compilation errors.
(On AS perl, 5.6.1). Term::ReadKey doesn't appear to use prototypes incidentally.
I'm intrigued - is there a functional difference between ReadMode 1; and ReadMode(1); and if so, what? Or am I being really, really dense?
Thanks.
Update: thanks to duff. I'd sort of always assumed that
andcallsub(); sub callsub{#dostuff}
were equivalent, and never encountered anything that proved me wrong. I know better now :-)sub callsub(){#dostuff} callsub();
--------------------------------------------------------------
"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".
Can you spare 2 minutes to help with my research? If so, please click here
In reply to 'function' calls without parentheses by g0n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |