"R. Joseph Newton" wrote:

Whoops.  Forgot the most important function.  Inine

> Overall, I would suggest that you steer clear of internal references in your
> objects when possible.  It is much better to make a container class, then delete
> contained objects from the container.  Generally you would want to avoid having
> other references to the contained objects, except through the methods of the
> container [Trainset] object.
>
> package Trainset;
>
> use strict, warnings et. al.;

use Trian;

>
>
> use Exporter;
>
> our @ISA = qw/Eporter/;
>
> sub new {
>
> sub add_track {
>    my $self = shift;
>
>    my $track = shift;
>    push @{$self->{'tracks'}}, $track;

   return @{$self->{'tracks'}} - 1;

> }

sub track {
   my $self = shift;

   my $track = Track-new(@_);
   push @{$self->{'tracks'}}, $track;
   return @{$self->{'tracks'}} - 1;
}

Which should give you a very nice pass-through approach to creating and adding new
train objects on the fly.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to