AutoSplit(3perl)
π NAME π
okay bestie, welcome to AutoSplit β the perl page you've been looking for π
AutoSplit - split a package for autoloading β¨
πΈ SYNOPSIS πΈ
autosplit($file, $dir, $keep, $check, $modtime);
autosplit_lib_modules(@modules);
π DESCRIPTION π
so this function literally chops your program up into files that the AutoLoader module knows how to deal with. Both the standard perl libraries and the MakeMaker utility use it to auto-configure libraries for autoloading, no cap. π«Ά
The autosplit interface splits the file you give it into a whole hierarchy rooted at the directory $dir. It makes directories as needed so the class hierarchy actually lines up, and it creates the file autosplit.ix. That file is doing double duty, bestie β it's both a forward declaration of all the package routines and the timestamp for the last update of the hierarchy. Iconic behaviour honestly. π
The other three arguments to autosplit control the rest of the autosplitter's behaviour:
π§ $keep
If the third argument, $keep, is false, then any pre-existing "*.al" files in the autoload directory get removed if they're no longer part of the module (those are the obsoleted functions, gone bestie π). $keep defaults to 0.
π¦ $check
The fourth argument, $check, tells autosplit to check the module it's currently splitting and make sure it includes a use specification for the AutoLoader module β and if AutoLoader is not detected, the module gets skipped. $check defaults to 1.
π $modtime
And lastly, $modtime says that autosplit should check the modification time of the module against the modification time of the autosplit.ix file, and only split the module if it's newer. $modtime defaults to 1.
Typical use of AutoSplit in the perl MakeMaker utility is via the command-line, like this β¨:
perl -e 'use AutoSplit; autosplit($ARGV[0], $ARGV[1], 0, 1, 1)'
Defined as a Make macro, it's invoked with file and directory arguments. autosplit splits the file you named into the directory you named, deletes those obsolete .al files, and it does all of that after checking that the module uses the AutoLoader, and making sure the module isn't already split in its current form (that's the modtime test, iykyk π΅οΈββοΈ).
The autosplit_lib_modules form is what gets used when perl itself is being built ποΈ. It takes as input a list of files (modules) that are assumed to live in a directory lib relative to the current directory. Each file gets sent to the autosplitter one at a time, to be split into the directory lib/auto.
Now β in both usages of the autosplitter, only subroutines defined following the perl __END__ token get split out into separate files. Some routines can be placed before that marker if you want to force them to load and parse immediately. periodt. π
π Multiple packages π
As of version 1.01 of the AutoSplit module, it's possible to have multiple packages inside a single file π₯³. Both of these cases are supported:
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 will let you know if it needs to create the top-level directory you specified when you invoked it. Ngl, it's preferred that the script or the installation process invoking AutoSplit already created the full directory path ahead of time. So if you're seeing this warning, it might be a sign that the module is being split into a wrong path π.
AutoSplit also warns you about every single subroutine whose name could cause potential file naming conflicts on machines with drastically limited file name length (8 characters or less). Since the subroutine name is the file name, these warnings are genuinely helpful for portability to systems like that π«Ά.
Warnings get issued and the file gets skipped if AutoSplit can't locate either the __END__ marker or a package Name;-style specification. Both missing = no splitting for you, sorry bestie π.
AutoSplit will also emit general diagnostics whenever it can't create directories or files.
π AUTHOR π
AutoSplit is maintained by the perl5-porters. Please direct any questions to the canonical mailing list π¬. Anything that applies to the CPAN release can be sent to its maintainer, though.
- Author and Maintainer: The Perl5-Porters
<perl5-porters@perl.org> - Maintainer of the CPAN release: Steffen Mueller
<smueller@cpan.org>
β COPYRIGHT AND LICENSE β
This package has been part of the perl core since the first release of perl5 π±. It's been released separately to CPAN so older installations can benefit from bug fixes too. So thoughtful fr fr.
This package has the same copyright and license as the perl core:
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:
- the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
- 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.
And now the β¨ interpretation section β¨, because this part is important:
For those of you that choose to use the GNU General Public License, the interpretation given here 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.
Linking in C subroutines in this manner is considered 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. (That's 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 that interpretation of the GPL. If you still have concerns or difficulties understanding the intent, feel free to contact the author π©. Of course, the Artistic License spells all this out for your protection, so you may prefer to use that one. Either way you're covered, bestie π
aaaand that's a wrap π this page ships with perl v5.44.0, dated 2026-10-17, from the Perl Programmers Reference Guide β go split some packages, you absolute icon π β¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms