# MAIN
use test::Foo;

my $x = new test::Foo ( 'SunSet',  'myID',  'myPassword' );
my $y = Clone($x);
my $z = $y -> Clone;

$y->{TEMPLATE} = 'SunRaise';
my $t = 'TEMPLATE';
print $$x{$t} . " " . $$y{$t} . " " . $$z{$t};


# test::Foo
package test::Foo;
use strict;

require Exporter;  our @ISA = qw/Exporter/;
our @EXPORT = qw/new Clone/;

sub Clone 
{ my $self ; my $class = shift;
  $self -> {$_} = $class -> {$_} for (keys %$class);
  return bless $self;
}

sub new
{ my $self; shift;
 $self -> {TEMPLATE} = shift;
 $self -> {ID} = shift;
 $self -> {Pass} = shift;
 bless $self;
 return $self; 
}
1;

Follow up on my previous post, I've get my thing cloned, but.. Is it right
way to make a clone like this ? Any more standard way to get the same
job done ?

Thanks in advise,
Bee

PS.  I have no idea why I do this or what's the purpose, it just a test
for learning purpose. It's just my very first step into OOPerl... 

Reply via email to