What is the meaning of the code block after the “usage module”?

What is the meaning and what is the effect of something like this (I think it is object oriented):

use My::Confusing::Code { CITY => { MODIFY => 1, DEFAULT => My::Even::more::complicated->func(), }, STATE => { MODIFY => 1, DEFAULT => 'Concatenate()', }, COUNTRY => { MODIFY => 1, REQUIRED => 0, DEFAULT => 'Gabon', }, } 

What My :: Confusing :: Code package / module / class would do with the material in braces. Do curly brackets insert a block of code or a hash link?

+6
module perl
source share
1 answer

This is a hash link.

When you execute use Module::Foo @stuff; what happens behind the scenes:

 BEGIN { require "Module/Foo.pm"; Module::Foo->import( @stuff ); }; 

Typically, the parameters passed to import are used to request the export of characters to the namespace. (A typical way to do this is to use the import routine from the standard Exporter module.) But in this case, the author wrote his own import method, which takes hashref and does something with it.

+13
source share

All Articles