home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _a18bc35c0835e88ee7548e7694c22ebc < prev    next >
Encoding:
Text File  |  2004-06-01  |  6.8 KB  |  261 lines

  1. =pod
  2.  
  3. =head1 NAME
  4.  
  5. ActiveState::RelocateTree - Relocate a Perl tree, substituting paths at the
  6. same time.
  7.  
  8. =head1 SYNOPSIS
  9.  
  10.    use ActiveState::RelocateTree qw(relocate);
  11.    relocate(from => 'C:\Perl', to => 'D:\lang\perl');
  12.  
  13. =head1 DESCRIPTION
  14.  
  15. ActiveState::RelocateTree relocates a Perl distribution wholesale into a new
  16. distribution. It comes with the script I<reloc_perl>, which is used to install
  17. the ActivePerl distribution into the final install location.
  18.  
  19. Perl can't just be copied into a new location without relocating some files.
  20. In Windows this is less of a problem because the executable knows its actual
  21. location and uses that to find its library tree. On Unix, the location of the
  22. libraries must be encoded within the perl binary. Most scripts also contain a
  23. "shebang" line of the form C<#!/path/to/perl>, which points at the absolute
  24. path of the Perl executable.
  25.  
  26. =head1 Using ActiveState::RelocateTree
  27.  
  28. The module exports four functions you can use to relocate Perl trees. You can
  29. also use these functions to search for and replace arbitrary strings in all
  30. files in a directory tree.
  31.  
  32. =head2 The relocate() Function
  33.  
  34.    relocate(%options);
  35.  
  36. This is the main entry point that applications will use. It has reasonable
  37. defaults, so in most cases you probably just call it like this:
  38.  
  39.    relocate(to => $to_path);
  40.  
  41. The following are all recognized options:
  42.  
  43. =over 4
  44.  
  45. =item F<to>
  46.  
  47. The tree which must be transformed. Unless the I<inplace> option is true, it
  48. will copy the tree at I<from> to I<to> before transforming it. This option is
  49. required.
  50.  
  51. =item F<from>
  52.  
  53. The path from which to copy the Perl tree. Defaults to C<$Config{prefix}>, the
  54. home of the currently executing perl interpreter.
  55.  
  56. =item F<search>
  57.  
  58. This is the path which will be searched for and replaced in I<to>. This
  59. defaults to the value of I<from>.
  60.  
  61. =item F<replace>
  62.  
  63. The replacement value for I<search>. This defaults to the value of I<to>.
  64.  
  65. =item F<inplace>
  66.  
  67. If the tree at I<to> already exists and you just want to transform it in-situ,
  68. use this option. It skips the copying step and just transforms the tree.
  69. If I<from> equals I<to>, it is set to true and cannot be unset. Otherwise it
  70. defaults to false.
  71.  
  72. =item F<killorig>
  73.  
  74. If you're really moving the tree, this option will remove I<from> after
  75. copying and transforming I<to>. Use with care! Defaults to false.
  76.  
  77. =item F<bak>
  78.  
  79. While relocating the tree, relocate() creates a backup file for each file
  80. being edited. This option allows you to specify the extension of backup files.
  81. Defaults to C<.~1~>.
  82.  
  83. =item F<savebaks>
  84.  
  85. Normally relocate() deletes the backup files before returning. I<savebaks>
  86. skips that step, leaving the backup files alone. Defaults to false (backups
  87. are deleted).
  88.  
  89. =item F<textonly>
  90.  
  91. Normally relocate() edits both text and binary files. Text files are replaced
  92. using a normal search-and-replace algorithm, but binary files are NULL-padded
  93. so that all offsets remain the same. By default, I<textonly> is false, i.e.
  94. relocate() operates on both text and binary files.
  95.  
  96. =item F<ranlib>
  97.  
  98. If I<ranlib> is true, relocate() will call C<ranlib> on binary files which
  99. look like library files (have the C<$Config{_a}> extension). Defaults to true.
  100.  
  101. =item F<verbose>
  102.  
  103. If I<verbose> is true, relocate() emits warning messages as it performs
  104. certain operations. This may be useful for debugging, or for command-line
  105. tools, where user feedback is a good thing.
  106.  
  107. =item F<quiet>
  108.  
  109. Normally, relocate() prints out some status messages even with I<verbose>
  110. disabled. If I<quiet> is true, all messages (except error messages) are
  111. temporarily silenced. This option overrides I<verbose>, so there isn't much
  112. point calling relocate() with both I<quiet> and I<verbose> set. By default,
  113. I<quiet> is false.
  114.  
  115. =item F<filelist>
  116.  
  117. If specified, relocate() will write a list of the files modified to
  118. I<filelist>, one filename per line.
  119.  
  120. =back
  121.  
  122. =head2 The move_tree() Function
  123.  
  124.    move_tree($from, $to, $delete_after, $verbose);
  125.  
  126. This is the function used to copy the tree from one place to another. It
  127. accepts the following parameters:
  128.  
  129. =over 4
  130.  
  131. =item $from
  132.  
  133. The source tree.
  134.  
  135. =item $to
  136.  
  137. The destination tree.
  138.  
  139. =item $delete_after
  140.  
  141. A boolean: if true, the tree at $from will be removed.
  142.  
  143. =item $verbose
  144.  
  145. A boolean: if true, it will print out a message when deleting the $from tree.
  146.  
  147. =back
  148.  
  149. =head2 The check() Function
  150.  
  151.    check($file, $regexp, $is_binary);
  152.  
  153. check() checks for occurrences of $from in $file. It is used by relocate() to
  154. search for files which should be edited. It accepts the following parameters:
  155.  
  156. =over 4
  157.  
  158. =item $file
  159.  
  160. The file to check.
  161.  
  162. =item $regexp
  163.  
  164. The regular expression to search for in the file.
  165.  
  166. =item $is_binary
  167.  
  168. A boolean: if true, check() uses binmode() on the filehandle before reading
  169. chunks of the file.
  170.  
  171. =back
  172.  
  173. =head2 The edit() Function
  174.  
  175.    edit($regexp, $from, $dest, $bak, $are_binary, @files);
  176.  
  177. edit() is designed to rip though a set of files, efficiently replacing $from
  178. with $dest. It operates on the whole set of files, which all need to be of the
  179. same type (binary or text). It accepts the following parameters:
  180.  
  181. =over 4
  182.  
  183. =item $regexp
  184.  
  185. The regular expression to search for. Matching text will be replaced with
  186. $dest.
  187.  
  188. =item $from
  189.  
  190. The path to search for and replace. If $are_binary is true, this is used to
  191. calculate the amount of NUL-padding required to preserve the length of strings.
  192. It is not used otherwise.
  193.  
  194. =item $dest
  195.  
  196. The replacement string. If $are_binary is true and $dest is shorter than
  197. $from, then it inserts a NULL-pad to preserve the original length of the
  198. strings.
  199.  
  200. =item $bak
  201.  
  202. The extension to use when storing backup files.
  203.  
  204. =item $are_binary
  205.  
  206. A boolean: if true, the files are edited with binary semantics: the
  207. filehandles are set to binmode, and strings are NULL-padded. Otherwise
  208. a plain-old substitution occurs.
  209.  
  210. =item @files
  211.  
  212. A list of files to edit.
  213.  
  214. =back
  215.  
  216. =head2 The spongedir() Function
  217.  
  218.    spongedir($name)
  219.  
  220. The spongedir() function returns the spongedir associated with a particular
  221. product. Currently, it only knows about PPM's spongedir.
  222.  
  223. =over 4
  224.  
  225. =item $name
  226.  
  227. The name of the spongedir you're interested in. It's case-insensitive, so you
  228. can ask for 'PPM', 'Ppm', or 'ppm', too.
  229.  
  230. The following spongedirs are defined:
  231.  
  232. =over 4
  233.  
  234. =item ppm
  235.  
  236. The sponge directory for PPM.
  237.  
  238. =item thisperl
  239.  
  240. The original directory in which this copy of Perl was built. This allows
  241. relocate() to detect when a replacement path will not fit into the binary.
  242.  
  243. =back
  244.  
  245. =back
  246.  
  247. =head1 SEE ALSO
  248.  
  249. See also L<reloc_perl>.
  250.  
  251. =head1 AUTHOR
  252.  
  253. ActiveState Corporation (support@ActiveState.com)
  254.  
  255. =head1 COPYRIGHT
  256.  
  257. Copyright (c) 2002, ActiveState Corp. All Rights Reserved.
  258. ActiveState is a devision of Sophos.
  259.  
  260. =cut
  261.