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

Perl: How to use class

Perl: How to use class

#!/usr/local/bin/perl -w
package Person ;
sub new{
    my $class = shift;
    my $person = {
        "Name"  => undef,
        "Occupation" => undef,
        "Email"  => undef,
    bless($person, $class);    
    sub set_Person{
        my $self = shift;
        my ($name, $occupation, $email)= @_;
        $self->{'Name'} = $name;
        $self->{'Occupation'}= $occupation;
        $self->{'Email'}= $email;
    sub get_Person{
    my $self = shift;
        print "$key: $valuen";
# Creating instances of classe 'Person'
$student = Person->new();
# Class initialization
$student->set_Person("Bill", "Gate", "bill@test.com");
# access class objects

Users who found this page were searching for:

  • python get username

No comments yet.

Leave a Comment