数组 – 我不明白这个Perl语法,有没有人有任何想法?
发布时间:2020-12-16 06:06:46 所属栏目:大数据 来源:网络整理
导读:我从Perl插件中获得了这部分内容.我不明白它的作用.它是关联数组的数组吗?如果是这样,那么它不应该以@开头吗?任何人都可以对这个问题有所了解吗? my $arguments = [ { 'name' = "process_exp",'desc' = "{BasePlugin.process_exp}",'type' = "regexp",'de
我从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 worldn"; } my %hash = ( call => &;foo ); &{ $hash{call} }; # this allows you to call the sub foo (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |