in reply to Re^2: Round numbers?
in thread Round numbers?
See Conditional Operator in perlop.for my $n (@nra) { my $fmt; if ($n > 0.001){ $fmt = '%5.2g'; } else { $fmt = '%5.3g'; } printf qq{$fmt \n}, $n; }
Note that
$x = $y > $z ? 'foo' : 'bar';
is perhaps more clearly written as
$x = ($y > $z) ? 'foo' : 'bar';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Round numbers?
by Anonymous Monk on Oct 02, 2009 at 00:51 UTC |