Burak Gürsoy wrote:
> 
> But I dont use bless on the first object, create a clone of it an use bless
> on the second one
> and return this second one. It looks like a bug to me.
 
ok, let me try again.

> #!/usr/bin/perl -w
> use strict;
> package Test::One;
> 
> sub new {
>    my $class = shift;
>    my $self  = {};

# here an anonymous hash is created.

>    bless $self, $class;

# here that hash is blessed into package Test::One

>    return $self;

# and the blessed thingie is returned

> }
> 
> package Test::Two;
> 
> sub new {
>    my $class   = shift;
>    my $test_it = shift;
>    my $self    = $test_it;
>    bless $self, $class;
>    return $self;
> }
> 
> package main;
> 
> my $test_one = Test::One->new();
> print "[Before] ref(\$test_one) = ",ref($test_one),"\n";
> print "$test_one\n"; 

# I added this to show what $test_one refers to. when I ran this
# I got this:

Test::One=HASH(0x1abf0ac)

# this shows the hash at '0x1abf0ac' has been blessed into
# package Test::One.

 
> my $test_two = Test::Two->new($test_one);

# when the Test::Two::new method is called, you are
# passing it the reference to the blessed anonymous hash.
# the Test::Two::new method reblesses that anonymous hash
# into the package Test::Two.

> print "[After ] ref(\$test_one) = ",ref($test_one),"\n";
> print "$test_two\n";

# again, let's see what $test_two contains. on my system, I
# got:

Test::Two=HASH(0x1abf0ac)

# this shows the hash at '0x1abf0ac' has been blessed into
# package Test::Two.

# I say again, this is what I expect.

# have a look at the perl documentation for references and
# objects:

http://www.perldoc.com/perl5.8.0/pod/perlref.html
http://www.perldoc.com/perl5.8.0/pod/perltoot.html

# HTH


-- 
Alan F. Dickey - Interaction and Realization
http://www.intac.com/~afdickey
mailto:[EMAIL PROTECTED]
VOX: 908-273-3232 Cell: 908-334-0932

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to