aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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