#!/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]); } catch (Error::Simple $ex) { print "Can't convert to integer!\n"; exit 1; } try { $d = Utils::stod($ARGV[1]); } catch (Error::Simple $ex) { print "Can't convert to floating point!\n"; exit 1; } print Utils::messageFormat("i + d = \{0:f\}", $i + $d), "\n"; }