in reply to Lists of objects and passing objects
Can I make a list of objects?Yup, since objects are just scalars e.g
use IO::File; my @list = map { IO::File->new($_) or die("ack: $!") } @ARGV;
Can an object create another object and pass it to yet another object.Indeed.
A little laboured perhaps, but the above example is basically demonstrating that an object is just a blessed reference, nothing too magical about it.sub Foo::new { bless {}, shift } sub Foo::get_bar { return Foo::Bar->new(); } sub Foo::Bar::new { bless {}, shift } sub Baz::new { bless { bar => pop }, shift } my $baz = Baz->new( Foo->new()->get_bar() ); print $baz->{bar},$/; __output__ Foo::Bar=HASH(0x80fbc2c)
_________
broquaint
|
|---|