数组 – 我不明白这个Perl语法,有没有人有任何想法?

数组 – 我不明白这个Perl语法,有没有人有任何想法?,第1张

概述我从Perl插件中获得了这部分内容.我不明白它的作用.它是关联数组的数组吗?如果是这样,那么它不应该以@开头吗?任何人都可以对这个问题有所了解吗? my $arguments = [ { 'name' => "process_exp", 'desc' => "{BasePlugin.process_exp}", 'type' => "regexp", 'deft' => 我从Perl插件中获得了这部分内容.我不明白它的作用.它是关联数组的数组吗?如果是这样,那么它不应该以@开头吗?任何人都可以对这个问题有所了解吗?

my $arguments =  [ { 'name' => "process_exp",'desc' => "{BasePlugin.process_exp}",'type' => "regexp",'deft' => &get_default_process_exp(),'reqd' => "no" },{ 'name' => "assoc_images",'desc' => "{MP4Plugin.assoc_images}",'type' => "flag",'deft' => "",{ 'name' => "applet_Metadata",'desc' => "{MP4Plugin.applet_Metadata}",'deft' => "" },{ 'name' => "Metadata_fIElds",'desc' => "{MP4Plugin.Metadata_fIElds}",'type' => "string",'deft' => "Title,Artist,Genre" },{ 'name' => "file_rename_method",'desc' => "{BasePlugin.file_rename_method}",'type' => "enum",'deft' => &get_default_file_rename_method(),# by default rename imported files and assoc files using this enCoding    'List' => $BasePlugin::file_rename_method_List,'reqd' => "no"  } ];
解决方法 正如Bwmat所说,它是对一组哈希引用的引用.读

$man perlref

要么

$man perlreftut     # this is a bit more straightforward

如果您想了解更多有关参考文献的信息.

顺便说一句,在Perl中,您可以这样做:

@array = ( 1,2 );          # declare an array$array_reference = \@array; # take the reference to that array$array_reference->[0] = 2;  # overwrite 1st position of @array$numbers = [ 3,4 ];        # this is another valID array ref declaration. Note [ ] instead of ( )

哈希也会发生同样的事情.

顺便说一句,您可以这样做:

%hash = ( foo => 1,bar => 2 );$hash_reference = \%hash; $hash_reference->{foo} = 2;$langs = { perl => 'cool',PHP => 'ugly' }; # this is another valID hash ref declaration. Note { } instead of ( )

并且……是的,您可以取消引用这些引用.

%{ $hash_reference }

将被视为哈希,所以如果你想打印上面的$langs键,你可以这样做:

print $_,"\n" foreach ( keys %{ $langs } );

要取消引用数组引用,请使用@ {}而不是%{}.甚至sub也可以被解除引用.

sub foo{  print "hello world\n";}my %hash = ( call => \&foo );&{ $hash{call} }; # this allows you to call the sub foo
总结

以上是内存溢出为你收集整理的数组 – 我不明白这个Perl语法,有没有人有任何想法?全部内容,希望文章能够帮你解决数组 – 我不明白这个Perl语法,有没有人有任何想法?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1213219.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存