choroba helped with the immediate problem, but maybe an example of common usage will help:
use strict; use warnings; package Pendulum; sub new { my ($class, %params) = @_; # Do interesting parameter validation here my $self = bless \%params, $class; # and other set up here. At this point you can call derived class +methods # as part of setup if you want using $self->methodName(); return $self; } package main; my $pit = Pendulum->new(Hz => 0.5);
Note in particular Pendulum->new(...) used to call the constructor
In reply to Re: Can't bless
by GrandFather
in thread Can't bless
by BernieC
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |