#! /usr/bin/perl

use strict;
use warnings;

# sample calculator program
print "\n === Welcome to Calc === \n";
print "enter your math expressions, one per line, and it will try to work out answers\n";
print "enter control-D when you are done\n\n";

# process the expressions, one per line
while (<STDIN>) {
  my $expr = $_;  # remove the newline from the current line
  unless ($expr) {
     last;               # quit if the expression is empty
  }
  my $answer = eval($expr); # use eval to compute an answer
  print "$answer = $expr\n";
}

print "\nBye!\n\n";

