Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Perl: Create an Inheritable Class

Perl: Create an Inheritable Class
{filelink=14329}

#!/usr/local/bin/perl -w
# création d'une classe
package Person;
sub new {
    my $class = shift;
    my $self  = { };
    return bless $self, $class;
}
sub name {
    my $self = shift;
    $self->{name} = shift if @_;
    return $self->{name};
}
sub occupation {
    my $self = shift;
    $self->{occupation} = shift if @_;
    return $self->{occupation};
}
 ######## inherit Class ###########
 package Customer;
 use Person;
my $client = Customer->new( );
$client->name("Jhon");
$client->occupation("Allien");
printf "I'm %s and %s.n", $client->name, $client->occupation;

Users who found this page were searching for:

  • python iterate dict
  • multipart/mixed tiedosto
  • create class perl
  • python fibonachi number calculator

No comments yet.

Leave a Comment