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

31 lines
375 B
Perl

#!/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__