programming-examples/perl/Class/The Class Constructor Method.pl

18 lines
428 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
# Module: House.pm
package House; # Class
sub new { #constructor
my $class = shift;
my $ref={"Owner"=>undef,
"Price" =>undef,
};
bless($ref, $class);
return $ref; # A reference to the object is returned
}
1;
# The User of the Module)
#!/usr/bin/perl
use House;
my $houseref = House->new();
print ref($houseref),".\n";