Perl 6 namespace and modular system

I am new to Perl and Perl 6. And I cannot accept the Perl 6 module / namespace / package system.

I am working on a library. Say the name of my company MyCompany. And the library is a "category Net. " So what should the file hierarchy look like? Should it be lib/MyCompany/Net/MyLibrary.pm? Or lib/Net/MyLibrary.pm? Or something else?

Also, should I override the definition of my class this way?

package MyCompany {
  class Net::MyLibrary { 
+4
source share
2 answers

:: - , , , CPAN Github. , , , . Perl 5 Perl6. Perl6. - Perl 5 ( class);

unit class MyCompany;

unit Perl 6, ( , package MyCompany; Perl 5 package ..). , .

class MyCompany { # so begins the MyCompany class
    method foo {
        return self;
    }

    ## ...other methods
} # the end of MyCompany

# code from other classes...

, .

+4

, . , . MyLibrary,

, .

, CPAN, . , MyCompany::. , , - , - .

, -, CPAN, , Net::, HTML::, Math:: ..

, , , CPAN. MyCompany:: . Net:: . MyCompany::Net::, MyModule, ,

MyCompany::Net::MyModule, MyCompany/Net/MyModule.pm. ,

+2

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


All Articles