in reply to Re^3: TK "textvariable" not updating with @var but ok with $var
in thread TK "textvariable" not updating with @var but ok with $var

This worked.
sub change_var1_1 { my $i; my @foo = change_var1_2(@var1); for ($i = 1; $i <= 81; $i++) { $var1[$i] = $foo[$i]; } $status = "change_var1_1 called $var1[3], $var1[5]"; }
As we know this isn't working...
sub change_var1_1 { @var1 = change_var1_2(@var1); $status = "change_var1_1 called $var1[3], $var1[5]"; }
Is there a better way? Should I just not be using arrays in the textvariables? i.e.  -textvariable => \$puz[25]

Replies are listed 'Best First'.
Re^5: TK "textvariable" not updating with @var but ok with $var
by huck (Prior) on Jan 27, 2017 at 01:27 UTC

    sub change_var1_1 { change_var1_2(\@var1); $status = "change_var1_1 called $var1[3], $var1[5]"; } sub change_var1_2 { my $var=shift; $var->[3] = 6; $status = "change_var1_2 called $var->[3]"; }

      (My termemology may be off here, I'm a hardware guy :)) I see, You can send the pointer to the array to the subroutine so that the subroutine knows which array to modify. This works for me !! Also, my appologies for caling it @var1. It actually highlights my 'wrong' thinking that you can treat an array just like a variable. (and this may be what you were saying, i.e. pointing out my 'wrong' thinking.) This code was actually a stripped down example (believe it or not) and as I replaced the original variables and arrays, I just picked @var1 and $var2. Thanks for your help, I understand now. Also, for my purpouses, This works just as well: (Note, I global replaced 'var1' with 'fee')
      my @some_arry_to_modify_by_the_sub; my @some_other_arry_to_modify_by_the_sub_with_the_same_structure_but_ +different_data; #some call like ---> change_fee_1(@some_arry_to_modify_by_the_sub); #or ---> change_fee_2(@some_arry_to_modify_by_the_sub) sub change_fee_1 { change_fee_2(@_); $status = "change_fee_1 called $_[3], $_[5]"; } sub change_fee_2 { $_[3] = 6; $status = "change_fee_2 called $_[3]"; }