关闭

perl文件句柄参数传递

标签: perlreference
2509人阅读 评论(0) 收藏 举报
分类:

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");

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:564180次
    • 积分:4923
    • 等级:
    • 排名:第5735名
    • 原创:13篇
    • 转载:114篇
    • 译文:0篇
    • 评论:29条
    文章分类
    最新评论