#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Config::Tiny; my $config = 'Config::Tiny'->read('config.properties'); my $operand1 = $config->{operation}{op1}; my $operand2 = $config->{operation}{op2}; my $operation = $config->{operation}{op}; my $is_integer = $config->{operation}{int}; my %dispatch = ('+' => sub { $_[0] + $_[1] }, '-' => sub { $_[0] - $_[1] }, '/' => sub { $_[0] / $_[1] }, '*' => sub { $_[0] * $_[1] }); my $action = $dispatch{$operation} or die "Unknown operation '$operation'.\n"; my $result = $action->($operand1, $operand2); $result = int $result if $is_integer; say $result;