package Stoplight; sub new { my ($class) = @_; my ($self) = {}; bless($self,$class); $self->{'color'} = "yellow"; my $var = $self->{'color'}; print("color: $var \n"); $self->{'_created'} = 1; return $self; } sub change { my ($self) = @_; my $val = $self->{'color'}; print(" color: $val \n"); if($val eq "red") { $self->{'color'} = "green"; } elsif($val eq "green") { $self->{'color'} = "yellow"; } elsif($val eq "yellow") { $self->{'color'} = "red"; } } 1;