http://qs321.pair.com?node_id=110867


in reply to Creating objects within objects being strange...

This comment is unrelated to your question, but I thought I'd mention something quickly that I've picked up recently and found very useful.

Consider writing your new functions something like this:

sub new { my $proto=shift; my $class=ref $proto || $proto; my $self={ @_ }; ## ... bless $self,$class; }

Then create your instance like this:

my $inst=new MyClass( name => 'mr.nick', rank => 'novice', sleep_level => 'not enough' );
I found that by directly putting the class parameters on the new() line like that makes for cleanliness, and readability. And, it makes for a real quick method of stuffing values into the instance of the object.

mr.nick ...