What is the colon in the qw declaration?

I am reading about Log4Perl from perl.com
The tutorial says: use Log::Log4perl qw(:easy);

What is : before easy ? Is this some kind of special syntax?

+6
source share
2 answers

This is a special syntax for specialized import lists , especially for export tags.

Here is an example of an example part of a module from this documentation.

 @EXPORT = qw(A1 A2 A3 A4 A5); @EXPORT_OK = qw(B1 B2 B3 B4 B5); %EXPORT_TAGS = (T1 => [qw(A1 A2 B1 B2)], T2 => [qw(A1 A2 B3 B4)]); 

The user of this module can say:

 use Module qw(:DEFAULT :T2); 

to import all names from the default set ( @EXPORT ) plus those defined in the T2 set.

If only...

the package in question overloads the import swap and does whatever it wants with the option, which apparently does this package according to the amesee answer .

+9
source

This is not special perl syntax. This is just some author-defined prefix that makes this line more like a value for configuration. You can see for yourself the definition of imports . It just looks for the value in the hash with the key :easy . Just a string consisting of the characters ':', 'e', ​​'a', 's', 'y'.

+4
source

Source: https://habr.com/ru/post/945873/


All Articles