加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl文件句柄参数传递

发布时间:2020-12-16 00:44:15 所属栏目:大数据 来源:网络整理
导读:The relationship between typeglobs,filehandles,and symbolic references is an ancient and mysterious one. Since filehandles cannot be stored directly in scalars,typeglobs used to be the only way to pass filehandles into or out of subroutine

The relationship between typeglobs,filehandles,and symbolic references is an ancient and mysterious
one. Since filehandles cannot be stored directly in scalars,typeglobs used to be the only way to pass
filehandles into or out of subroutines:


# example of passing a filehandle to a subroutine


sub print_to_filehandle {
$fh = shift;
print $fh @_;
}


# pass filehandle as typeglob


print_to_filehandle(*STDOUT,"Hello Passed Filehandle /n");


# pass filehandle as scalar reference to typeglob

$fh = *STDOUT;print_to_filehandle($fh,"Hello Again");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读