Re: Variable division, assignment and sprintf in one line



Gunnar Hjalmarsson wrote:
Steve Bertrand wrote:
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)))

You can write a function.

convert( $var );

sub convert { $_[0] = sprintf '%.2f', $_[0] / 2 ** 20 }

Thanks guys!

That's a neat piece of trickery that I'd never thought of!

Worked great!

Steve
.