Variable division, assignment and sprintf in one line



Hi again all,

Is there a way that one can use sprintf on a variable and assign the
value back to the variable without having the leading $var= ?

$var = sprintf ("%.2f", (($var /=1024) /=1024)))

I've got a hash of hashrefs of hashrefs and I'd rather not specify the
variable name on the left and right hand side if possible.

Tks,

Steve
.



Relevant Pages

  • Re: regular expr.
    ... You dont require regex for that use printf or sprintf ... print $var; ... HTH ...
    (perl.beginners)
  • RE: fixed width variable
    ... perldoc -f sprintf ... I have been searching for a way to do this and have not had any luck. ... $var would be 5. ...
    (perl.beginners)
  • Re: Variable division, assignment and sprintf in one line
    ... Is there a way that one can use sprintf on a variable and assign the ... it by another 1024, assign it again to $var, then format the ... at compile time and you'll only do a single division each ... -- Terry Pratchett in Sourcery ...
    (perl.beginners)