Hi all,

I have an perl oop problem.

I want to manipulate/set a variable for one instance of an object without changing the same variable for all instances of an object.

Thanks in advance for any help,

Regards,
Jeremy A.
-----------------------------------------------------------------------------------------------------------
here is some a script which, when executed, demonstrates my problem.

my $n = Test->new( PERSON => "jer");
my $g = Test->new(PERSON => "jon");


while(1)
{
$g->name();
$n->name();
$g->hair(); <------- this changes $hair var for both $g and $n objects, but i want it to only change for $g.


}

package Test;

use strict;
use warnings;

my $hair = "n/a";


sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { 'PERSON' => undef, @_, };

return bless $self, $class;

}


sub hair { $hair = "brown"; }


sub name { my ($s) = @_; print $s->{PERSON},":$hair\n"; }



1;

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

Reply via email to