ActiveState::RelocateTree - Relocate a Perl tree, substituting paths at the same time. |
relocate()
Functionmove_tree()
Functioncheck()
Functionedit()
Functionspongedir()
Function
ActiveState::RelocateTree - Relocate a Perl tree, substituting paths at the same time.
use ActiveState::RelocateTree qw(relocate); relocate(from => 'C:\Perl', to => 'D:\lang\perl');
ActiveState::RelocateTree relocates a Perl distribution wholesale into a new distribution. It comes with the script reloc_perl, which is used to install the ActivePerl distribution into the final install location.
Perl can't just be copied into a new location without relocating some files.
In Windows this is less of a problem because the executable knows its actual
location and uses that to find its library tree. On Unix, the location of the
libraries must be encoded within the perl binary. Most scripts also contain a
``shebang'' line of the form #!/path/to/perl
, which points at the absolute
path of the Perl executable.
The module exports four functions you can use to relocate Perl trees. You can also use these functions to search for and replace arbitrary strings in all files in a directory tree.
relocate()
Functionrelocate(%options);
This is the main entry point that applications will use. It has reasonable defaults, so in most cases you probably just call it like this:
relocate(to => $to_path);
The following are all recognized options:
$Config{prefix}
, the
home of the currently executing perl interpreter.
relocate()
creates a backup file for each file
being edited. This option allows you to specify the extension of backup files.
Defaults to .~1~
.
relocate()
deletes the backup files before returning. savebaks
skips that step, leaving the backup files alone. Defaults to false (backups
are deleted).
relocate()
edits both text and binary files. Text files are replaced
using a normal search-and-replace algorithm, but binary files are NULL-padded
so that all offsets remain the same. By default, textonly is false, i.e.
relocate()
operates on both text and binary files.
relocate()
will call ranlib
on binary files which
look like library files (have the $Config{_a}
extension). Defaults to true.
relocate()
emits warning messages as it performs
certain operations. This may be useful for debugging, or for command-line
tools, where user feedback is a good thing.
relocate()
prints out some status messages even with verbose
disabled. If quiet is true, all messages (except error messages) are
temporarily silenced. This option overrides verbose, so there isn't much
point calling relocate()
with both quiet and verbose set. By default,
quiet is false.
relocate()
will write a list of the files modified to
filelist, one filename per line.
move_tree()
Functionmove_tree($from, $to, $delete_after, $verbose);
This is the function used to copy the tree from one place to another. It accepts the following parameters:
check()
Functioncheck($file, $regexp, $is_binary);
check()
checks for occurrences of $from in $file. It is used by relocate()
to
search for files which should be edited. It accepts the following parameters:
check()
uses binmode()
on the filehandle before reading
chunks of the file.
edit()
Functionedit($regexp, $from, $dest, $bak, $are_binary, @files);
edit()
is designed to rip though a set of files, efficiently replacing $from
with $dest. It operates on the whole set of files, which all need to be of the
same type (binary or text). It accepts the following parameters:
spongedir()
Functionspongedir($name)
The spongedir()
function returns the spongedir associated with a particular
product. Currently, it only knows about PPM's spongedir.
The following spongedirs are defined:
relocate()
to detect when a replacement path will not fit into the binary.
See also reloc_perl.
ActiveState Corporation (support@ActiveState.com)
Copyright (c) 2002, ActiveState SRL. All Rights Reserved.
ActiveState::RelocateTree - Relocate a Perl tree, substituting paths at the same time. |