aboutsummaryrefslogtreecommitdiff
path: root/challenge-031
diff options
context:
space:
mode:
authorYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2019-10-22 23:09:44 +0800
committerYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2019-10-22 23:09:44 +0800
commit298111357d5fd6141b5944aacb00a17279063592 (patch)
tree5ca0d6129eb9e759bd079556b072f2d7fe30672c /challenge-031
parent8cba287d10540749782a4daee77bccb1c251945a (diff)
downloadperlweeklychallenge-club-298111357d5fd6141b5944aacb00a17279063592.tar.gz
perlweeklychallenge-club-298111357d5fd6141b5944aacb00a17279063592.tar.bz2
perlweeklychallenge-club-298111357d5fd6141b5944aacb00a17279063592.zip
Added perl6 solution ch#31-1
Diffstat (limited to 'challenge-031')
-rw-r--r--challenge-031/yet-ebreo/perl5/ch-1.pl1
-rw-r--r--challenge-031/yet-ebreo/perl6/ch-1.p619
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-031/yet-ebreo/perl5/ch-1.pl b/challenge-031/yet-ebreo/perl5/ch-1.pl
index ffe41c3a6e..4bf4f6a896 100644
--- a/challenge-031/yet-ebreo/perl5/ch-1.pl
+++ b/challenge-031/yet-ebreo/perl5/ch-1.pl
@@ -1,3 +1,4 @@
+#!/usr/bin/perl
#Create a function to check divide by zero error
#without checking if the denominator is zero.
use strict;
diff --git a/challenge-031/yet-ebreo/perl6/ch-1.p6 b/challenge-031/yet-ebreo/perl6/ch-1.p6
new file mode 100644
index 0000000000..678e3cfd58
--- /dev/null
+++ b/challenge-031/yet-ebreo/perl6/ch-1.p6
@@ -0,0 +1,19 @@
+#Create a function to check divide by zero error
+#without checking if the denominator is zero.
+
+sub div_zero_check ($n, $d) {
+ my $r;
+ try {
+ $r = $n / $d;
+
+ #Error is not raised when the result of division is not used
+ say $r;
+ }
+
+ $! && say "Division by zero detected";
+}
+
+div_zero_check(112,0);
+div_zero_check(0,0);
+div_zero_check(0,1);
+div_zero_check(32,12); \ No newline at end of file