in reply to weird problem with macports perl on apple m1/m2 based system
I modified your code to get rid of the evals. With some luck, this may fix your (unidentified) problem.
#!/usr/bin/env perl use strict; use warnings; use POSIX; use Tk; my %pid; %pid=( DCDC_A_51=>{cmd=>'22 46 5B', cu=>'51', desc=>'DC/DC output curren +t t30', unit=>'A', d=>2, formula=>sub{sprintf("%.2f", U1 +6(1,4)/16)}}, DCDC_V_51=>{cmd=>'22 46 5C', cu=>'51', desc=>'DC/DC output voltag +e t30', unit=>'V', d=>2, formula=>sub{sprintf("%.2f", U1 +6(25,253)/512)}, val=>'---'}, DCDC_W_51=>{ desc=>'DC/DC power output' +, unit=>'W', action=>sub{sprintf("%.0f", ($ +pid{DCDC_V_51}{val} * $pid{DCDC_A_51}{val}))}, val=>'---'} ); my $mw=MainWindow->new(); $mw->Button(-text=>" Test ", -command=>sub{test()}, -font=>'Helvet +ica 18 bold', -pady=>20)->pack(); MainLoop; sub test { $pid{DCDC_V_51}{val}=$pid{DCDC_V_51}{formula}->(); print $pid{DCDC +_V_51}{val} ."\n"; $pid{DCDC_A_51}{val}=$pid{DCDC_A_51}{formula}->(); print $pid{DCDC +_A_51}{val} ."\n"; $pid{DCDC_W_51}{val}=$pid{DCDC_W_51}{action}->(); print $pid{DCDC_W_51}{val} ."\n"; } sub U16 { my($a,$b)=@_; return ($a*256+$b); }
"These opinions are my own, though for a small fee they be yours too."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: weird problem with macports perl on apple m1/m2 based system
by perltux (Monk) on Jun 10, 2023 at 21:49 UTC |