How to create an object : Object « Class « Perl






How to create an object

  

#First we create an anonymous hash, 
#then bless it into a package

package House;

my $ref = { "Owner"=>"Tom", 
            "Price"=>"25000", # Properties/attributes
          };
bless($ref, House);

print "\$ref is: $ref.\n";
print ref($ref), ".\n";

   
    
  








Related examples in the same category