diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-07 13:54:59 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-07 13:54:59 +0000 |
| commit | 46feb1df62a59a15249d33326743d3d756418fd7 (patch) | |
| tree | e3823a75442b1dcf2ee8fdc933b789e56545d530 /challenge-042 | |
| parent | 5dee2d01ef6239a3007c16d8241c1eab33d36805 (diff) | |
| download | perlweeklychallenge-club-46feb1df62a59a15249d33326743d3d756418fd7.tar.gz perlweeklychallenge-club-46feb1df62a59a15249d33326743d3d756418fd7.tar.bz2 perlweeklychallenge-club-46feb1df62a59a15249d33326743d3d756418fd7.zip | |
- Added solution by Fabrizio Poggi.
Diffstat (limited to 'challenge-042')
| -rw-r--r-- | challenge-042/fabrizio-poggi/perl/ch-1.pl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-042/fabrizio-poggi/perl/ch-1.pl b/challenge-042/fabrizio-poggi/perl/ch-1.pl new file mode 100644 index 0000000000..9cf656fb89 --- /dev/null +++ b/challenge-042/fabrizio-poggi/perl/ch-1.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl
+use strict;
+use warnings;
+
+my $x;
+my $y;
+my $mod;
+my $oct;
+my @array;
+
+foreach $x (0..50){
+ print "Decimal $x = ";
+ if ($x < 8) {
+ $oct = $x;
+ } else {
+ do {
+ $y = int($x / 8);
+ $mod = $x % 8;
+ push (@array, $mod);
+ $x = $y;
+ } while ($x > 8);
+ push (@array, $x);
+ $oct = reverse @array;
+ }
+print "Octal $oct \n";
+@array=();
+}
|
