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';
In reply to Re^3: Round numbers?
by AnomalousMonk
in thread Round numbers?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |