来自Sys::Info::Device:
If DEVICE_ID has the value of available, then the names of the available devices will be returned.
为什么$info->device('available');
在至少有cpu-device时才返回设备?
#!/usr/local/bin/perl
use warnings;
use 5.014;
use Sys::Info;
my $info = Sys::Info->new;
my @available = $info->device('available');
say 'Available devices: ', scalar @available;
my $cpu = $info->device( 'CPU' );
say 'Number of cores: ', $cpu->count;
输出:
可用设备:0
核心数量:2