I dont understand this Perl Syntax,anyone has any idea?

Question!

I have got this part from a perl plugin.But I dont understand what does it do?Is it an array of associative arrays?If so then shouldnt it be started wuth @?Can anyone shed some light on this issue?

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' => "",
    'reqd' => "no" },
  { 'name' => "applet_metadata",
    'desc' => "{MP4Plugin.applet_metadata}",
    'type' => "flag",
    '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"
  } ];
By : MiNdFrEaK


Answers

Looks like a hash of hashes reference.

you may need to dereference like

%newhash = %{$arguments}

and print the data as

print $newhash{'name'}

By : huskeer


$arguments is an array reference (a reference/pointer to an array)

You initialize arrays with () and array references with []

my @array = ( 1, 2, 3 );
my $array_ref = [ 1, 2, 3 ];

You can create a reference with \

my $other_array_ref = \@array;

When you use an array reference you will then to dereference it when using:

for my $element ( @{$array_ref} )

or

print ${$array_ref}[0];

See man perlref

Back to your question: $arguments is a reference to an array of hash references (initialized with {})

By : Matteo


As Bwmat said it's a reference to an Array of Hash references. Read

$ man perlref

or

$ man perlreftut     # this is a bit more straightforward

for if you want to know more about references.

By the way in fiew words in Perl you can do:

@array = ( 1, 2 );          # declare an array
$array_reference = \@array; # take the reference to that array
$array_reference-
By : dave


This video can help you solving your question :)
By: admin