gpt4 book ai didi

windows - Perl 包问题

转载 作者:可可西里 更新时间:2023-11-01 11:39:55 24 4
gpt4 key购买 nike

我是 Perl 新手。

我下载了一个 perl 应用程序,在源文件中有这样一行:

 use PWING::Utils::Utils;

它似乎导入了一个文件。

我下载了 Eclipse [Perl-Eclipse 集成] 的插件。当我尝试将该文件作为 perl 应用程序启动时,它说找不到导入的资源。

现在的问题是,perl 包结构是什么样的?

那一行意味着必须有一个像这样的目录结构:

    PWING - 
Utils -
Utils.pm ?

我看到我下载的应用程序不包含这样的结构,那么应该如何启动?

最佳答案

perlmod文档状态

All Perl module files have the extension .pm. The use operator assumes this so you don't have to spell out "Module.pm" in quotes. This also helps to differentiate new modules from old .pl and .ph files. Module names are also capitalized unless they're functioning as pragmas; pragmas are in effect compiler directives, and are sometimes called "pragmatic modules" (or even "pragmata" if you're a classicist).

The two statements:

require SomeModule;
require "SomeModule.pm";

differ from each other in two ways. In the first case, any double colons in the module name, such as Some::Module, are translated into your system's directory separator, usually "/".

...

Perl packages may be nested inside other package names, so we can have package names containing ::. But if we used that package name directly as a filename it would make for unwieldy or impossible filenames on some systems. Therefore, if a module's name is, say, Text::Soundex, then its definition is actually found in the library file Text/Soundex.pm.

特价@INC数组包含要搜索模块的目录:

@INC

The array @INC contains the list of places that the do EXPR, require, or use constructs look for their library files. It initially consists of the arguments to any -I command-line switches, followed by the default Perl library, probably /usr/local/lib/perl, followed by ".", to represent the current directory. ("." will not be appended if taint checks are enabled, either by -T or by -t.) If you need to modify this at runtime, you should use the use lib pragma to get the machine-dependent library properly loaded also:

use lib '/mypath/libdir/';
use SomeMod;

关于windows - Perl 包问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3227580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com