Hmm. Well, when creating the sub objects, I could create a 'register' type method in the master that would add a link to the child object inside the master object, which could be set as you indicated. I can't tie the master state to the child objects (as there could be different states depending on the number of units being monitored), however when that unit gets triggered I could test if there is a linked object, and then set it at that point.

Something to think about, thanks!

On Mon, Nov 25, 2013 at 1:47 PM, Kevin Robert Keegan <> wrote:
If you can, you probably want the state of the Master object to be set to the recently changed unit_number, or at least to some state to note that a new unit_number has been received.  If you do this, you can use the "tie_event" routine to trigger your set routine to run.  It probably makes sense for your master item and slave item objects to be different classes.

For example, something like this would work:

package Master_Item;


sub master_event{
my ($self, $p_state) = @_;
if ($p_state eq 'SOME TEST'){

package Slave_Item;

sub new {
my ($class,$master) = @_;
bless $self, $class;
$$self{master} = $master;
$$self{master}{slave} = $self;
$$self{master} -> tie_event ('$object->master_event("$state")');
return $self;


Anytime the state of the master object changes, master_event is run.  You would obviously need to expand this so it could work with many slave items, but that should be trivial.

On Mon, Nov 25, 2013 at 12:09 PM, H Plato <> wrote:
I'm probably missing something obvious, but it's been a while since I played with creating an object.
I want to create a 'linked' type of object, that is one that will respond when a master object has changed. This master object listens to serial data, and will set it's internal structure based on what it sees. so when

$unit= $object->unit_now method equals a value, that means that an activity has taken place with this particular unit.
$object->unit_state($unit) method will give the state of that particular code

So using examples, I can craft up an object package, however I'm unclear how to link in the set method such that it fires when $object->unit_now equals the unit number stored in the object. My rough outline is below, I appreciate any feedback or suggestions object creators may have:

package test_item;

@test_item::ISA = ('Base_Item');

sub initialize
   my ($self,$object,$unit) = @_;

   $$self{unit_number} = $unit;
   $$self{master_object} = $object; #should be a reference to the original object, don't know if this syntax is correct

sub set
   my ($self,$p_state,$p_setby) = @_;

    if (unit_now $self->{master_object} eq $self->{unit_number}) {
       if ($self->{master_object}->unit_state($self->unit_number) =~ /^series1/) {
            $p_state = 'on';
         } elsif ($self->{master_object}->unit_state($self->unit_number) =~ /^series2/) {
            $p_state = 'off';


Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
To unsubscribe from this list, go to: