Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    Scalar::Util::Clone 0.04

    Download button

    No screenshots available
    Downloads: 355  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    chocolateboy | More programs
    Perl Artistic License / FREE
    August 27th, 2007, 01:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Scalar::Util::Clone description

    Scalar::Util::Clone can recursively copy datatypes using perl's builtin functions.

    Scalar::Util::Clone can recursively copy datatypes using perl's builtin functions.

    SYNOPSIS

    use Scalar::Util::Clone qw(clone);

    $a = Foo->new();
    $b = { alpha => 'beta', gamma => 'vlissides' };

    tie %c, 'Foo::Bar';

    $d = clone($a);
    $e = clone($b);
    $f = clone(%c);

    # or

    my $node2 = {
    name => 'node2',
    children => [ $node3, $node4 ],
    parent => weaken ($node1) # weaken() to avoid memory leak
    };

    my $clone = clone($node2);

    This module exports a clone() function which unlocks the builtin functionality perl uses to clone a new interpreter and its values. As such, it is capable of cloning all perl datatypes, including weak references, hashes with shared keys, hashes with UTF8 keys, restricted hashes, tied variables, regex objects, and other curios lurking in Perl's intestines. Because the clone operation is performed at the lowest level, copying the datatype's internals rather than reconstructing it via the public API, the operation is fast and comprehensive, and produces values that exactly match their original (for instance, Data::Dumper dumps of hashes are always guaranteed to be the same as those of the original).

    For performance reasons, the following types are passed through transparently rather than being deep cloned: formats, code refs, typeglobs, IO handles, and stashes.

    clone returns a recursive copy of its argument, which can be an arbitrary (scalar) type including nested HASH, ARRAY and reference types, tied variables and objects.

    To duplicate non-scalar types (e.g. lists, ARRAYs and HASHes), pass them to clone by reference. e.g.

    my $copy = clone (@array);

    # or

    my %copy = %{ clone (%hash) };

    For a slower, but more flexible solution see Storable's dclone.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    copy datatypes | Perl functions | Perl module | Scalar | datatypes | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM