Re: [mh] eval'ing perl to create MH mqtt objects

Tom MacLean <[email protected]> Wed, 27 Oct 2021 16:21:25 -0400
Newsgroups gmane.comp.misc.misterhouse.user
Message-ID <[email protected]>

So, I have played with this more.  I notice that I cannot create any objects in my *.pl scripts -- if I do I get the complaint that "Global symbol $x requires explicit package name".  Is there a workaround for that, or must all objects be created in MHT files?

Thanks,
Tom

On 2021-10-20 22:43, Tom MacLean wrote:
> 
> Hi All,
> I apologize for being a hack .. despite using MH for almost 20 years,
> my perl knowledge is poor.
> I'm am trying to programatically make MQTT clones of specific MH
> objects by calculating a new name, a suitable MQTT topic name and then
> eval'ing the code to create the object and tie it to the original
> object:
> This code is in a sub that receives the object I am linking to "mh_obj":
> eval "$new_obj_name = new mqtt_Item(\$mqtt_1, \"$mqtt_topic\");";
> eval "$mh_obj_name->tie_event('sync_mqtt($mh_obj_name, $new_obj_name,0)');";
> The first line runs without errors (or visible result).  The second
> line runs successfully (because the event gets tied), but the
> $new_obj_name object isn't visible, I get 'Global symbol
> "$Basement_Landing_mqtt" (this is $new_obj_name) requires explicit
> package name'.  So the tied event code does not see the object I
> created in the first eval.
> What went wrong?  Is my eval scope only that of the sub, and once the
> sub ends my created object dies?  Is there a way this can work?
> Thanks,
> Tom


________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users