use Complex; #create a new object my $x = new Complex; #create a new object with initial values my $y = new Complex(5, -3); $x->Real(3); #set $x's real part to '3' $x->Imag(-5); #set $x's imaginary part to '-5' print $x->Real." ".$y->Imag; #prints '3 -3'