1

我是 Perl 的新手。

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

 use PWING::Utils::Utils;

它看起来像导入了一个文件。

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

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

该行意味着必须有这样的目录结构:

    PWING - 
          Utils - 
                 Utils.pm ?

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

4

2 回答 2

3

perlmod文档状态

所有 Perl 模块文件都有扩展名.pm. 运营商假设这一点,use因此您不必"Module.pm"在引号中拼写出来。这也有助于将新模块与旧模块.pl.ph文件区分开来。模块名称也是大写的,除非它们用作编译指示;pragma 实际上是编译器指令,有时称为“实用模块”(如果您是古典主义者,甚至称为“pragmata”)。

两种说法:

require SomeModule;
require "SomeModule.pm";

在两个方面彼此不同。在第一种情况下,模块名称中的任何双冒号,例如Some::Module,都被翻译成系统的目录分隔符,通常是“/”。

...

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.

The special @INC array contains directories to be searched for modules:

@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;
于 2010-07-12T12:13:47.103 回答
0

在 Unix 系统上,该文件可以在以下形式的目录中找到

 lib/PWING/Utils/Utils.pm

但问题是检测顶级目录“lib”可能在哪里。

如果该模块安装在您的系统上,它将被放置在 Perl 可以找到的地方。

于 2010-07-12T11:14:06.097 回答