editi has asked for the wisdom of the Perl Monks concerning the following question:
i tried the following example to learn the class .
but it shows the following error.
Can't call method "name" on an undefined value at ClassWithPrg.pl line 17.
plz help me to rectify this error.
Source code
thankyou#!/usr/bin/perl -w sub new() { my $self={}; $self->{FORM_VAR}=undef; bless($self); return $self->{FORM_VAR}; } sub name() { $self->{FORM_VAR}=shift; print "Using the constructor\n\n\n"; return $self->{FORM_VAR}; } + $obj=main->new(); $var=$obj->name("KALAI"); print "Here ::: $var\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regarding Perl Class Object
by Sidhekin (Priest) on Feb 22, 2007 at 06:46 UTC | |
|
Re: Regarding Perl Class Object
by klekker (Pilgrim) on Feb 22, 2007 at 08:21 UTC | |
|
Re: Regarding Perl Class Object
by Moron (Curate) on Feb 22, 2007 at 12:36 UTC | |
by Anno (Deacon) on Feb 22, 2007 at 13:26 UTC | |
| |
| A reply falls below the community's threshold of quality. You may see it by logging in. |