For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2005 > Fwd: how to run perl class?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Fwd: how to run perl class?
Tech tech417

2005-08-24, 7:55 am

---------- Forwarded message ----------
From: Tech tech417 <tech417@gmail.com>
Date: Aug 24, 2005 3:09 PM
Subject: Re: how to run perl class?
To: Xavier Noria <fxn@hashref.com>


Hi,

Create Person.pm with following contents:

package Person;

sub new
{
my($type) =3D $_[0];
my($self) =3D {};
$self->{'name'} =3D $_[1];
bless($self, $type);
return($self);
}

sub tellname
{
my($self)=3D$_[0];
print "Person name is $self->{'name'}.\n";
}
1;

and calling script test.pl is:

use Person;
$obj =3D Person->new('Prabahar');
$obj->tellname();

Now run the test.pl script.

# perl test.pl
Person name is Prabahar.

Thanks.


On 8/24/05, Xavier Noria <fxn@hashref.com> wrote:
>
> On Aug 24, 2005, at 9:39, praba har wrote:
>
>
> Perl is case-sensitive: "package".
>
>
> Does /Users/enmail/perl/Person.pm exist?
>
> -- fxn
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com