You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
561 B
Perl

5 years ago
# Module: House.pm
package House;
sub new{
my $class = shift;
my ($owner, $salary) = @_;
my $ref={"Owner"=>$owner,
"Price"=>$price,
};
bless($ref, $class);
return $ref;
}
sub display_object {
my $self = shift;
while( ($key, $value)=each %$self){
print "$key: $value \n";
}
}
1;
# main.pl
#!/usr/bin/perl
my $house1 = House->new("A", 2);
my $house2 = House->new("B", 5);
$house1->display_object;
$house2->display_object;
print "$house1, $house2\n";