in reply to Re: Regarding Perl Class Object
in thread Regarding Perl Class Object

That works. But only because you have two errors that (fortuitously) pretty much cancel each other out.

sub new() { my $self={}; $self->{FORM_VAR}=undef; bless($self); return $self; }

You should always use the two-argument version of bless. Your constructor should look like this:

sub new { my $class = shift; my $self = {}; # some initialisation bless($self, $class); return $self; }

But that doesn't work here because you have this:

my $obj = main::new();

You're calling new() as a function, not as a class method, so it doesn't get passed the class name.

You should invoke the constructor as a class method.

my $obj = main->new();

Perl doesn't strictly differentiate between functions and methods. But the programmer should.