想知道 Perl 中的句柄是什么。
我可以看到文件句柄、目录句柄等,但想知道 Perl 中句柄的含义。
例如,在 IO::Pipe 中,我可以看到下面的解释。并想弄清楚“成为把手”的含义?
reader ([ARGS])
The object is re-blessed into a sub-class of IO::Handle,
and becomes a handle at the reading end of the pipe. If
ARGS are given then fork is called and ARGS are passed
to exec.
Run Code Online (Sandbox Code Playgroud)
另外可以解释一下bless的意思吗?
这是我遇到困难的旧 Perl 脚本的一部分。
变量$h突然在内部定义if,我无法弄清楚它的含义。
#!/usr/bin/perl
use strict;
use warnings;
use Scalar::Util qw(looks_like_number);
if (open(LIST,"/proc/partitions"))
{
while (<LIST>)
{
my @a = split(/\s+/);
print "@a\n";
if (looks_like_number($a[3]) && $a[3] > 100000000)
{
if (open(IN, "/dev/$a[4]"))
{
my $h;
if (read(IN, $h, 4) == 4 && $h eq 'EFI')
{
print "/dev/$a[4]\n";
}
close(IN);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它实际上是代码的一部分。
无论如何,它运行良好,但据我所知,没有任何内容被保存到变量中$h并且只是定义了。
与 相关吗looks_like_number?
你能告诉我我想念什么吗?