box-o-sand/cli/ex01/b.pl

31 lines
375 B
Perl
Raw Normal View History

2011-01-06 03:32:28 +00:00
#!/usr/bin/env perl
use strict;
use warnings;
my $num = 4000 / 7;
print "$num\n";
print int($num + 0.005) . "\n";
printf("%.3f\n", $num);
printf("00%.3f\n", $num);
sub show_signed {
my ($num) = @_;
if ($num gt 0) {
printf("+%.3f\n", $num);
} else {
printf("%.3f\n", $num);
}
}
show_signed($num);
show_signed($num - 1000);
1;
__END__