如何创建一个IO :: All对象来读取文件处理ARGV和DATA?
use strict;
use warnings;
use 5.010_000;
use IO::All;
# none of these work...
my $io = io->handle(DATA);
my $io = io->handle(\*DATA);
my $f = \*DATA;
my $io = io->handle($f);
my $io = io->handle({$f});
my $io = io->handle({DATA});
my $io = io->handle({\*DATA});
say $io->slurp();
__DATA__
FOO
BAR
QUUX
Run Code Online (Sandbox Code Playgroud)
看起来像个bug.即使文档说它应该,传入句柄似乎也不起作用.这是一个消除可能的复杂性的例子DATA
.
use strict;
use warnings;
use IO::All;
open my $fh, "<", "/etc/passwd" or die $!;
# Either of these should work according to the docs.
# my $io = IO::All->new($fh);
my $io = io->file->handle($fh);
print $io->all;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
165 次 |
最近记录: |