How can you defend a language that says, 'When using print() the file handle should not have a comma after it'. Could you explain that (I doubt it).
I'll bite. This is known as "indirect object syntax," and is fully explained in perlobj. The idea is that when calling a subroutine on a particular object, you need to distinguish the object itself from the additional arguments. So for example, if I write print $a, $b, "foo"; it knows to print the values $a, $b, and "foo" as a list of strings separated by $, (blank by default). However, if I write print $a $b, "foo"; it knows that $a should be treated as a filehandle and I should print the list ($b, "foo") to it. You wouldn't want to make this distinction at runtime because a) some objects can be treated as both strings and filehandles and b) if you screwed up you'd rather get an error than accidentally print to STDOUT.
| [reply] [d/l] [select] |