Net::CUPS->getDestinations() 输出

Net::CUPS->getDestinations() output

我正在尝试使用 Net::CUPS->getDestinations() 获取在 CUPS 中配置的打印机名称列表。

像这样的简短演示程序

#!/usr/bin/perl
use strict;
use warnings;
use Net::CUPS;
my $cups = Net::CUPS->new();
my @prts = $cups->getDestinations();
foreach my $printer (@prts) {
  print "$printer\n";
}
exit;

的输出为

Net::CUPS::Destination=SCALAR(0x1e13bb0)
Net::CUPS::Destination=SCALAR(0x1e13bf8)
Net::CUPS::Destination=SCALAR(0x1e13c88)
Net::CUPS::Destination=SCALAR(0x1e13d18)
Net::CUPS::Destination=SCALAR(0x1e13d00)
Net::CUPS::Destination=SCALAR(0x1e4c9c8)

我需要打印机名称,或者我可以传递给另一个函数以获取打印机名称的东西。 看来我对这部分文档的解释有误。

getDestinations
    my @printers = $cups->getDestinations();
 This method will return an array of destinations currently configured  on the cups server.

有谁知道如何使用 Net::CUPS 模块获取在 CUPS 中配置的打印机列表?

感谢 Arunesh Singh,稍微改变一下 foreach 循环就是解决方案。 我现在意识到 getDestinations() 正在返回一个对象数组。

#!/usr/bin/perl
use strict;
use warnings;
use Net::CUPS;
my $cups = Net::CUPS->new();
my @prts = $cups->getDestinations();
foreach my $printer (@prts) {
  my $name = $printer->getName();
  print "$name\n";
}
exit;