home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / Docs / RISCOS-Library-Docs / Clone.pm < prev    next >
Text File  |  1999-04-17  |  2KB  |  50 lines

  1. NAME
  2.     RISCOS::Clone -- copy nested structures.
  3.  
  4. SYNOPSIS
  5.         use RISCOS::Clone qw(clone);
  6.         @copy = clone (@original);
  7.  
  8.         $copy = $original->Clone();
  9.  
  10.  
  11. DESCRIPTION
  12.     This module provides functions to copy structures.
  13.  
  14.     Clone <hash_ref>
  15.         copies a hash reference, `bless'ing the returned hash with
  16.         the class (if any) of the original. `Clone' uses <clone> to
  17.         copy each hash value.
  18.  
  19.     clone <object> ...
  20.         recursively copies the objects passed in. In list contest
  21.         returns the copied objects, in scalar context returns the
  22.         first object. `clone' copies `undef', scalars, code
  23.         referencess and globs unchanged, scalar references are
  24.         copied as a reference to scalar containing the identical
  25.         value. Array references are passed recursively to `clone',
  26.         hash references to `Clone'. Blessed references that posses a
  27.         `Clone' method have this method called, else `Clone' is
  28.         called to make a copy.
  29.  
  30.         `clone' is simpleminded and will go wrong as follows.
  31.  
  32.             clone will loop on structures that refer to themselves
  33.             clone will copy things that may not want duplication
  34.               (eg RISCOS::Font objects have a dummy Clone method to stop this)
  35.             clone will not work correctly if hashes are supposed to be keyed with a
  36.               stringified reference.
  37.             Clone will C<die> if blessed references are not hash references.
  38.  
  39.  
  40.         For objects these problems can be overcome by writing a
  41.         custom `Clone' method.
  42.  
  43.  
  44. BUGS
  45.     Caveats as noted above. Not tested enough yet.
  46.  
  47. AUTHOR
  48.     Nicholas Clark <nick@unfortu.net>
  49.  
  50.