(updated to correct my hexi->hexa but leave the Q link wrong)
That's the end of the practical answer. Flight of fancy follows...
But there is a problem with that. If some well-meaning code tries to change our value, we lose either the string or numeric value:$ perl -wlne'eval;print$@if$@ # interactive perl' use Scalar::Util 'dualvar'; $x = dualvar(256, sprintf "%x", 256); print $x; 100 # correct hexadecimal string print 0+$x; 256 # correct numeric value
Kind of makes you want some way to turn on a readonly flag for a scalar you've set up this way.$x .= "foo"; print 0+$x; Argument "100foo" isn't numeric in addition (+) at (eval 9) line 1, <> + line 8. 100 print $x; 100foo $x = dualvar(256, '100'); $x += 3; print 0+$x; 259 print $x 259
In reply to Re: passing hex argument as string
by ysth
in thread passing hex argument as string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |