How do I choose a package name for a custom Perl module that does not collide with builtin or CPAN packages names?

前端 未结 6 563
南方客
南方客 2020-11-30 03:37

I have read the perldoc on modules, but I don\'t see a recommendation on naming a package so it won\'t collide with builtin or CPAN module/package names.

In the past

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 04:03

    The @INC variable contains a list of directories to in which to look for modules. It starts with the first entry and then moves on to next if it doesn't find the request module. @INC has a default value that created when perl is compiled, but you can can change it with the PERL5LIB environment variable, the lib pragma, and directly manipulating the @INC array in a BEGIN block:

    #!/usr/bin/perl
    
    BEGIN {
        @INC = (); #no modules can be found
    }
    
    use strict; #error: Can't locate strict.pm in @INC (@INC contains:)
    

提交回复
热议问题