From: Gregg L. <gr...@li...> - 2008-03-18 18:26:37
|
John R. wrote: > Hello, > > I have the following incomplete and non-working user code: > > my @events = ( > [ 'entry', '01:01 PM', '40' ], > [ 'kitchen1', '06:23 AM', 62 ], > > ); > > for my $i ( 0 .. $#events ) { > if (time_now $events[$i][1]) { > ${$events[$i][0]}->set("ON"); bad ------------------------------^^^^ ON or 'on' or "on"; never "ON" > } > } > > Of course, this generates an error because of ${$events[$i][0]}: > > "Can't use string ("entry") as a SCALAR ref while "strict refs" in > use at (eval 383) line 3227." > > Maybe there is a way of turning off "strict" single line, but is there a > way to refer to the light items in an alternate way? Like as a hash or > something? for my $i ( 0 .. $#events ) { if (time_now $events[$i][1]) { my $light = &::get_object_by_name($events[$i][0]); $light->set(ON) if $light; } } Gregg |