> G'day...
>
> I've noticed a lot of modules can be initialised in the form:
>
> my $instance = Module->new( option => "value1", option2 => "value2" )
>
> How is this implemented? Is the above simply passing a hash reference?
>
> Is it something like:
>
[snippage snipped]
>
> TIA!
>
>
>
Hi,
You can create a "new" function as follows:
package X;
sub new {
my $init = shift;
my $class = ref($init) || $init;
my $self = {};
#or if you want to pre-initialize some values, you can do:
#my $self = {option1 => 'value1', option2 => 'value2};
return bless($self, $class);
}
Teddy
-
Big thanks to Larry and Edward for their help.
Regards,
Michael S. E. Kraus
Software Developer
Wild Technology Pty Ltd
___
ABN 98 091 470 692
Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017, Australia
Telephone 1300-13-9453 | Facsimile 1300-88-9453
http://www
On Thu, 02 Dec 2004 16:20:17 +1100, Michael Kraus
<[EMAIL PROTECTED]> wrote:
I've noticed a lot of modules can be initialised in the form:
my $instance = Module->new( option => "value1", option2 => "value2" )
How is this implemented? Is the above simply passing a hash reference?
Any function, in