#!/usr/bin/perl -- use strict; use warnings; my $op = shift @ARGV; my %ops = ( 'add' => sub { my $s = 0; $s += $_ for @_; print "The sum is: $s\n" }, 'multiply' => sub { my $p = 1; $p *= $_ for @_; print "The product is: $p\n" } ); $ops{$op}(@ARGV) if exists $ops{$op};