内容

名称

AutoSplit - 拆分包以进行自动加载

概要

autosplit($file, $dir, $keep, $check, $modtime);

autosplit_lib_modules(@modules);

描述

此函数将把您的程序拆分成 AutoLoader 模块可以处理的文件。它被标准 Perl 库和 MakeMaker 实用程序用来自动配置库以进行自动加载。

autosplit 接口将指定的文件拆分成以目录 $dir 为根的层次结构。它根据需要创建目录以反映类层次结构,并创建文件 autosplit.ix。此文件充当所有包例程的前向声明,以及层次结构最后更新的时间戳。

autosplit 的剩余三个参数控制着自动分割器的其他选项。

$keep

如果第三个参数 $keep 为假,则如果任何现有的 *.al 文件不再是模块的一部分(已过时的函数),则会从自动加载目录中删除它们。$keep 默认值为 0。

$check

第四个参数 $check 指示 autosplit 检查当前正在分割的模块,以确保它包含对 AutoLoader 模块的 use 规范,如果未检测到 AutoLoader,则跳过该模块。$check 默认值为 1。

$modtime

最后,$modtime 参数指定 autosplit 检查模块的修改时间与 autosplit.ix 文件的修改时间,并且仅在模块更新时才分割模块。$modtime 默认值为 1。

在 perl MakeMaker 实用程序中,AutoSplit 的典型用法是通过命令行使用

perl -e 'use AutoSplit; autosplit($ARGV[0], $ARGV[1], 0, 1, 1)'

定义为 Make 宏,它使用文件和目录参数调用;autosplit 将把指定的文件分割到指定的目录中,并删除过时的 .al 文件,首先检查模块是否使用 AutoLoader,并确保模块目前没有以其当前形式分割(modtime 测试)。

autosplit_lib_modules 形式用于构建 perl。它以文件(模块)列表作为输入,这些文件被假定位于当前目录的 lib 目录中。每个文件一次发送到自动分割器,以分割到 lib/auto 目录中。

在自动分割器的两种用法中,仅在 perl __END__ 标记之后定义的子例程被分割成单独的文件。一些例程可以放置在此标记之前,以强制立即加载和解析它们。

多个包

从 AutoSplit 模块的 1.01 版本开始,可以在单个文件中包含多个包。以下两种情况都受支持

package NAME;
__END__
sub AAA { ... }
package NAME::option1;
sub BBB { ... }
package NAME::option2;
sub BBB { ... }

package NAME;
__END__
sub AAA { ... }
sub NAME::option1::BBB { ... }
sub NAME::option2::BBB { ... }

DIAGNOSTICS

AutoSplit 将通知用户是否需要创建调用中指定的顶级目录。最好是调用 AutoSplit 的脚本或安装过程提前创建了完整的目录路径。此警告可能表明模块正在分割到错误的路径中。

AutoSplit 会警告用户所有子程序,其名称在文件命名长度极其有限(8 个字符或更少)的机器上会导致潜在的文件命名冲突。由于子程序名称用作文件名,因此这些警告可以帮助提高在这些系统上的可移植性。

如果 AutoSplit 无法找到 __END__ 标记或 "package Name;"-style 规范,则会发出警告并跳过该文件。

AutoSplit 还会发出无法创建目录或文件的通用诊断信息。

作者

AutoSplit 由 perl5-porters 维护。请将任何问题直接发送到规范的邮件列表。不过,任何适用于 CPAN 版本的内容都可以发送给它的维护者。

作者和维护者:Perl5-Porters <[email protected]>

CPAN 版本的维护者:Steffen Mueller <[email protected]>

版权和许可

此软件包自 perl5 首次发布以来一直是 perl 核心的一部分。它已单独发布到 CPAN,以便旧版本可以从错误修复中受益。

此软件包具有与 perl 核心相同的版权和许可证

             Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
        2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
        by Larry Wall and others
    
			    All rights reserved.
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of either:
    
	a) the GNU General Public License as published by the Free
	Software Foundation; either version 1, or (at your option) any
	later version, or
    
	b) the "Artistic License" which comes with this Kit.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either
    the GNU General Public License or the Artistic License for more details.
    
    You should have received a copy of the Artistic License with this
    Kit, in the file named "Artistic".  If not, I'll be glad to provide one.
    
    You should also have received a copy of the GNU General Public License
    along with this program in the file named "Copying". If not, write to the 
    Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
    02111-1307, USA or visit their web page on the internet at
    http://www.gnu.org/copyleft/gpl.html.
    
    For those of you that choose to use the GNU General Public License,
    my interpretation of the GNU General Public License is that no Perl
    script falls under the terms of the GPL unless you explicitly put
    said script under the terms of the GPL yourself.  Furthermore, any
    object code linked with perl does not automatically fall under the
    terms of the GPL, provided such object code only adds definitions
    of subroutines and variables, and does not otherwise impair the
    resulting interpreter from executing any standard Perl script.  I
    consider linking in C subroutines in this manner to be the moral
    equivalent of defining subroutines in the Perl language itself.  You
    may sell such an object file as proprietary provided that you provide
    or offer to provide the Perl source, as specified by the GNU General
    Public License.  (This is merely an alternate way of specifying input
    to the program.)  You may also sell a binary produced by the dumping of
    a running Perl script that belongs to you, provided that you provide or
    offer to provide the Perl source as specified by the GPL.  (The
    fact that a Perl interpreter and your code are in the same binary file
    is, in this case, a form of mere aggregation.)  This is my interpretation
    of the GPL.  If you still have concerns or difficulties understanding
    my intent, feel free to contact me.  Of course, the Artistic License
    spells all this out for your protection, so you may prefer to use that.