- 论坛徽章:
- 0
|
本帖最后由 sjdy521 于 2012-08-27 16:38 编辑
发现一个现象:
use IO::Handle之后,类似STDOUT、STDERR之类的句柄就可以继承IO::Handle,用oo的形式使用,比如:
STDOUT->autoflush(1);
我看了一下IO::Handle以及其他一些相关联的模块的源代码,并没有发现什么代码产生了这种效果。
我的疑问是,perlobj里有提到:
When you call a method, the thing on the left side of the arrow is passed as the first argument to the method. That means when we call Critter->new() , the new() method receives the string "Critter" as its first argument. When we call $fred->speak() , the $fred variable is passed as the first argument to speak() .
按照这样的理解,那么STDOUT->autoflush(1)就相当于是STDOUT::autoflush(STDOUT,1);
但显然事实上不是这样的。
想了解下,具体是哪里的代码产生这种效果,还是说,perl内部针对文件句柄做了特殊的处理? |
|