Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Class::Clone 0.05

    Download button

    No screenshots available
    Downloads: 498  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.5/5)
    14 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Tyler MacDonald | More programs
    Perl Artistic License / FREE
    April 17th, 2008, 03:14 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Class::Clone description

    Class::Clone is a Perl module to create a subclass or a copy of a class on-the-fly.

    Class::Clone is a Perl module to create a subclass or a copy of a class on-the-fly.

    SYNOPSIS

    # Another::Package gets its methods from Some::Package,
    # but to SUPER:: in Another::Pacakge will go to Another::Package::Super,
    package Some::Package::Super;
    sub method {
    my $class = shift;
    return "method";
    }

    package Some::Package;
    sub method {
    my $class = shift;
    return $class->SUPER::method . "ical";
    }

    package Another::Package::Super;
    sub method {
    return "naut";
    }

    package main;
    use Class::Clone qw(class_clone);
    use Test::More qw(no_plan);

    @Some::Package::ISA = qw(Some::Package::Super);
    class_clone('Some::Package', 'Another::Package');

    @Another::Package::ISA = qw(Another::Package::Super);

    is(
    Another::Package->method,
    'nautical',
    "Another::Package's namespace is completely independant of Some::Package"
    );

    Class::Clone makes an exact clone of an existing class, whose variables and subroutines are not in any way tied back to the existing class or it's parent classes. If you change any variables in the clone, the changes don't affect the parent class. When a cloned subroutine has a call like

    $self->SUPER::do_something()

    the clone class's parents are traversed. This module is called Class::Clone because this behaviour lends itself well to creating certain types of factory / polymorph classes.

    (This is in contrast to importing variable or subroutine references from other packages, typically via 'Exporter'. When you do that, your copy is the original copy, so changing inherited variables affects your parent packages, and SUPER:: will call the original parent's parent, even if you change your @ISA)

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    subclass creator | class clone | Perl module | Perl | class | subclass

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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