What is the significance 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 would the My::Confusing::Code package/module/class do with the stuff in the curly braces. Do the curly braces enclose a code block or a hash reference?
It's a hash reference.
When you do use Module::Foo @stuff;
, what's happening behind-the-scenes is:
BEGIN {
require "Module/Foo.pm";
Module::Foo->import( @stuff );
};
Normally, the parameters passed to import
are used to ask for symbols to be exported into your namespace. (The typical way to do this is to use the import
subroutine from the standard Exporter module.) But in this case, the module author has written a custom import
method that takes a hashref and does stuff with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With