Create a function to check for a divide-by-zero error without checking if the denominator is zero (i.e. using exception handling).
Instead of manually asserting if the divisor is 0 using conditional checks (e.g. if ($div == 0)), we attempt to execute the division inside an exception handling block. In Perl, we use the classic and robust Try::Tiny module (capturing the error in catch and returning "ERROR"). In Python, we use the standard try-except ZeroDivisionError block to cleanly catch division by zero.
Create a script to demonstrate creating dynamic variable name, assigning a value to the variable, and finally printing the variable. The variable name is passed as command line argument.
In Perl, variable names can be dynamically resolved using symbolic references by temporarily disabling reference strictures: no strict 'refs'. We then assign via ${$var_name} = $val. In Python, variables in the local or global namespace can be dynamically accessed and assigned via dictionary access on globals() or passing a custom scope mapping.