Re: Variable division, assignment and sprintf in one line
- From: iaccounts@xxxxxxxxxx (Steve Bertrand)
- Date: Wed, 28 Nov 2007 15:25:36 -0500
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
.
- References:
- Variable division, assignment and sprintf in one line
- From: Steve Bertrand
- Re: Variable division, assignment and sprintf in one line
- From: Gunnar Hjalmarsson
- Variable division, assignment and sprintf in one line
- Prev by Date: Re: fixed list combinatorics
- Next by Date: Re: fixed list combinatorics
- Previous by thread: Re: Variable division, assignment and sprintf in one line
- Next by thread: Re: Variable division, assignment and sprintf in one line
- Index(es):