了解 Musicbrainz cpan 模块的输出类型?
我使用 Musicbrainz cpan 模块来查找专辑,但在尝试破译我收到的输出时遇到了一些问题。我使用 data::Dumper 来查看它,它似乎是某种哈希或数组,但是当我尝试检查类型时遇到了问题。
my $ws = WebService::MusicBrainz::Release->new();
my $response = $ws->search({ TITLE => 'ok computer' });
if (ref($response) eq "REF" || ref($response) eq "SCALAR" || ref($response) eq "ARRAY" || ref($response) eq "HASH" || ref($response) eq "CODE" || ref($response) eq "GLOBE")
{
print "\n What sort of thing is it? \n";
}
谢谢
Im using the Musicbrainz cpan module to look up an album but Im having a few issues trying to decipher the output I recieve. I used data::Dumper to have a look at it, and it appears to be a hash or array of some sort but when I try to check the type I run into problems.
my $ws = WebService::MusicBrainz::Release->new();
my $response = $ws->search({ TITLE => 'ok computer' });
if (ref($response) eq "REF" || ref($response) eq "SCALAR" || ref($response) eq "ARRAY" || ref($response) eq "HASH" || ref($response) eq "CODE" || ref($response) eq "GLOBE")
{
print "\n What sort of thing is it? \n";
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它是一个 WebService::MusicBrainz::Response 对象。
It's a WebService::MusicBrainz::Response object.
就像已经说过的,它是一个 WebService::MusicBrainz::Response 对象。
您可以通过访问 release_list() 来检索多个结果,它提供 WebService::MusicBrainz::Response::Release 对象。
但是,该 perl 模块有些缺乏维护,并且它所使用的 XML Web 服务版本 1 已被弃用。
您最好使用 Web 服务的版本 2。
python-musicbrainzngs 提供了一个使用新(下一代方案)Web 服务的 python 模块。
Like already said, it is a WebService::MusicBrainz::Response object.
You can retrieve multiple results with accessing the release_list() which gives an array of WebService::MusicBrainz::Response::Release objects.
However, that perl module is somewhat unmaintained and the XML Web service Version 1 it is using is deprecated.
You better use Version 2 of the Web Service.
With python-musicbrainzngs there is a python module available that uses the new (next generation scheme) Web Service.