From: Bruce W. <br...@mi...> - 2002-12-12 03:50:19
|
When you do something like this: $light = new X10_Item('A1'); $light_override_table{$light} = $flag; You are converting the $light object reference into a string, since keys to a hash must be strings. So while it may still look like the real object, it is not really. Only its string representation (X10_Item=HASH(0x8d584c0)) looks the same. To make a list of objects for later use, you must store them as values in either a list or hash array. For example: push @list_lights, $light; or $lights_by_name{$name} = $light; Bruce -----Original Message----- Perl is complaining at me: "Error in user code: Can't locate object method "state_now" via package "X10_Item=HASH(0x8d584c0)" (perhaps you forgot to load "X10_Item=HASH(0x8d584c0)"?) at (eval 357) line 1878." This is when I evaluate the expression "state_now $light". I think state_now is a reasonable thing to call on $light, because when I call "state_now $den_lantern_light" it works fine. And $light and $den_lantern_light are eq! So .... duh ... why does it complain about "state_now $light"? Here's the code that generates the error. The last thing printed (before the above error message) is "MADE IT HERE". foreach my $light (keys %light_override_table) { my $val = $light_override_table{$light}; if (-1 == $val) { $light_override_table{$light} = 0; print_log "Clearing code-set of light in override_table"; } else { print_log "BURP $light"; if ($light eq $den_lantern_light) # for rest of this code, $light and $den_lantern_light are same object { print_log "MADE IT INSIDE THE LOOP BODY"; if ((state_now $den_lantern_light) eq ON) # state_now works OK { print_log "Now why does this work?"; } print_log "MADE IT HERE"; if ((state_now $light) eq ON) # this state_now doesn't work !!! { print_log "Now why does this NOT work?"; } print_log "MADE IT ALL THE WAY THROUGH!"; } } } ------------------------------------------------------- This sf.net email is sponsored by: With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel http://hpc.devchannel.org/ ________________________________________________________ To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365 |