#!/usr/bin/env perl use utf8; use Error::Simple; use Nice::Try; use Utils; use strict; use warnings; ############################################################################### # To use try/catch in Perl you must install the TryCatch module using cpan. # # > sudo cpan -i TryCatch ############################################################################### MAIN: { my $i = 0; my $d = 0; try { $i = Utils::stoi($ARGV[0]); $d = Utils::stod($ARGV[1]); print Utils::messageFormat("i + d = \{0:f\}", $i + $d), "\n"; } catch (Error::NumberFormatException $ex) { print "Can't convert command line argument!\n"; } catch (Error::Simple $ex) { print "Don't know what went wrong!\n"; } # Perl doesn't support true finally blocks { print "This statement always executes.\n"; } }