#!/usr/bin/perl -w # # Calculator Module Base Program. You are to write the # "Calculator.pm" module that is used by this program. It should # export the subroutines parse_line, plus, minus, divide, and # multiply. # use strict; use Calculator; my %operator = ( "+" => \&plus, "-" => \&minus, "/" => \÷, "*" => \&multiply ); while(<>) { chomp; last if /^exit$/; my($op, $n1, $n2) = parse_line($_); if (exists $operator{$op}) { my $result = $operator{$op}->($n1, $n2); print "$n1 $op $n2 = $result\n"; } else { warn "Invalid operator \"$op\"\n"; next; } }