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.

31 lines
575 B
Perl

#Employee.pm
package Employee;
sub new{
my $class = shift;
$ref={};
bless($ref, $class);
return $ref;
}
sub DESTROY{
my $self = shift;
print "Employee $self->{Name} is being destroyed.\n";
}
1;
#!/usr/bin/perl
use Employee;
my $emp1 = Employee->new;
{ my $emp2 = Employee->new;
$emp2->{"Name"}="Tom";
print "$emp2->{'Name'}\n";
}
my $emp3 = Employee->new;
$emp1->{"Name"}="Dan";
$emp3->{"Name"}="Tom";
print "$emp1->{'Name'}\n";
print "$emp3->{'Name'}\n";