However, this hash is used by various subroutines, and @minor_frame_data varies with each time subroutine call. Is there a way to define this once and pass it into each subroutine, where it's updated as necessary? I'd like to avoid globals, obviously, but realize that if I declaremy (%frame_lookup_by) = ( 21 => { desc => "S/W Status", value => sub { $minor_frame_data[0]*256 + $minor_frame_dat +a[1]} , }, 33 => { desc => "HK Subcom", value => sub { $minor_frame_data[1] % 16 } , #modu +lo 16 of w12 }, 117 => { desc => "General Status", value => sub {$minor_frame_data[0]*256 + $minor_frame_data +[1] }, }, 129 => { desc => "Sensor Status", value => sub {$minor_frame_data[0]*256 + $minor_frame_data +[1] }, }, );
in each subroutine, the @minor_frame_data in the has of subroutines and the current subroutine are in different lexical scopes, and thus contain different values. I want the values calculated in each subroutine to be derived from the current values in @minor_frame_data. In other words, the followingmy @minor_frame_data
should yield 257 if @minor_data = (1,1). Similarly,$ref_frame_lookup_by->{21}->{value}->()
should yield 1 if @minor_data = (1,1).$ref_frame_lookup_by->{33}->{value}->()
How can I write it so the @minor_frame_data values from the current subroutine are used instead of the ones in the original lexical scope?
In reply to Updating hash of subroutines by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |