Home > Archive > PERL Beginners > August 2005 > 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 |
how to run perl class?
|
|
| Praba Har 2005-08-24, 3:55 am |
| Dear All,
I try to run a sampleclass example program
in perl. But I received error. How to avoid it?
The code is below:
Package Person;
sub new
{
my($type) = $_[0];
my($self) = {};
$self->{'name'} = $_[1];
bless($self, $type);
return($self);
}
sub tellname
{
my($self)=$_[0];
print "Person name is $self->{'name'}.\n";
}
return(1);
Class calling program is below:
*******************************
se lib $ENV{"HOME"}."/perl";
print $ENV{"HOME"}."\n";
use Person;
$obj = Person->new('Prabahar');
$wr->tellname();
error report is below:
**********************
Can't locate Person.pm in @INC (@INC contains:
/Users/enmail/perl
/System/Links/Libraries/perl5/5.8.7/i686-linux
/System/Links/Libraries/perl5/5.8.7
/System/Links/Libraries/perl5
/System/Links/Libraries/perl5/site_perl/5.8.7/i686-linux
/System/Links/Libraries/perl5/site_perl/5.8.7
/System/Links/Libraries/perl5/site_perl
/Programs/Perl/5.8.7/lib/perl5/5.8.7/i686-linux
/Programs/Perl/5.8.7/lib/perl5/5.8.7
/Programs/Perl/5.8.7/lib/perl5/site_perl/5.8.7/i686-linux
/Programs/Perl/5.8.7/lib/perl5/site_perl/5.8.7
/Programs/Perl/5.8.7/lib/perl5/site_perl .) at
class_calling.pl line 3.
BEGIN failed--compilation aborted at class_calling.pl
line 3.
How I need to run this script.
regards
Prabahar
________________________________________
____________
Send a rakhi to your brother, buy gifts and win attractive prizes. Log on to http://in.promos.yahoo.com/rakhi/index.html
| |
| Muthukumar 2005-08-24, 3:55 am |
| On 8/24/05, praba har <prabaperl@yahoo.co.in> wrote:
> Dear All,
>=20
> I try to run a sampleclass example program
> in perl. But I received error. How to avoid it?
> The code is below:
>=20
> Package Person;
>=20
> sub new
> {
> my($type) =3D $_[0];
> my($self) =3D {};
> $self->{'name'} =3D $_[1];
> bless($self, $type);
> return($self);
> }
>=20
> sub tellname
> {
> my($self)=3D$_[0];
> print "Person name is $self->{'name'}.\n";
> }
>=20
> return(1);
>=20
> Class calling program is below:
> *******************************
> se lib $ENV{"HOME"}."/perl";
> print $ENV{"HOME"}."\n";
> use Person;
> $obj =3D Person->new('Prabahar');
> $wr->tellname();
>=20
> error report is below:
> **********************
>=20
> Can't locate Person.pm in @INC (@INC contains:
> /Users/enmail/perl
> /System/Links/Libraries/perl5/5.8.7/i686-linux
> /System/Links/Libraries/perl5/5.8.7
> /System/Links/Libraries/perl5
> /System/Links/Libraries/perl5/site_perl/5.8.7/i686-linux
> /System/Links/Libraries/perl5/site_perl/5.8.7
> /System/Links/Libraries/perl5/site_perl
> /Programs/Perl/5.8.7/lib/perl5/5.8.7/i686-linux
> /Programs/Perl/5.8.7/lib/perl5/5.8.7
> /Programs/Perl/5.8.7/lib/perl5/site_perl/5.8.7/i686-linux
> /Programs/Perl/5.8.7/lib/perl5/site_perl/5.8.7
> /Programs/Perl/5.8.7/lib/perl5/site_perl .) at
> class_calling.pl line 3.
> BEGIN failed--compilation aborted at class_calling.pl
> line 3.
> How I need to run this script.
You have to include Person.pm location in @INC location. As,
@INC=3D(@INC,.);
or
run perl with -I option also.
perl -I. <perlfile>
hth.
| |
| Xavier Noria 2005-08-24, 3:55 am |
|
On Aug 24, 2005, at 9:39, praba har wrote:
> Dear All,
>
> I try to run a sampleclass example program
> in perl. But I received error. How to avoid it?
> The code is below:
>
> Package Person;
Perl is case-sensitive: "package".
> Can't locate Person.pm in @INC (@INC contains:
> /Users/enmail/perl
Does /Users/enmail/perl/Person.pm exist?
-- fxn
|
|
|
|
|