use v5.34.0;
use warnings;
use feature qw(try);
no warnings "experimental::try";
sub div {
my ( $x, $y ) = @_;
die "@{[join ':', caller]}: Domain error: div($x, $y)" if $x == 0 and $y == 0;
$x / $y;
}
try {
div( 1, 0 )
}
catch ($e) {
warn "At @{[__FILE__]} line @{[__LINE__]}: $e"
}
try {
div( 0, 0 )
}
catch ($e) {
warn "At @{[__FILE__]} line @{[__LINE__]}: $e"
}
To embed this project on your website, copy the following code and paste it into your website's HTML: