我从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