#!/usr/bin/perl -w use strict; my $op = shift or die "You must specify an operation followed by numbers.\n"; die "Non-numeric input.\n" if grep /\D/, @ARGV; my %perform = ( add => sub { local $" = "+"; eval "@ARGV"; }, multiply => sub { local $" = "*"; eval "@ARGV"; }, ); die "Invalid operation.\n" unless defined $perform{$op}; print $perform{$op}->();