perl文件句柄的传递
perl 返回文件句柄的2种方式
1.使用 \*
#!/usr/bin/perl use strict; sub openfile() { my $path=shift; open(FILE,"$path") or die "Can't open $path $!\n "; return \*FILE; } my $temp=&openfile("config"); my @file=<$temp>; print @file;
2.使用变量
#!/usr/bin/perl use strict; sub openfile() { my $file; my $path=shift; open($file,"$path") or die "Can't open $path $!\n "; #close($file); return $file; } my $temp=&openfile("config"); my @file=<$temp>; print @file;
转载请注明出处:http://www.cnblogs.com/tobecrazy/