| 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>
>
>
>
|