Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: a2a895cb7e
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (22 sloc) 0.595 kB
#!/usr/bin/perl
use strict;
use warnings;
# find the modules, even if they are not installed. You don't need that
# if the module is installed
use lib '../lib/';
use lib 'lib';
use Math::Expression::Evaluator;
my $m = Math::Expression::Evaluator->new();
# obtain an expression to evaluate, either from the command line
# or from STDIN:
my $expr = shift @ARGV;
unless ($expr){
print "Please enter a mathematical expression:\n";
$expr = <STDIN>;
}
my $result = eval { $m->parse($expr)->val(); };
if ($@) {
print "There was an error\n";
} else {
print "Result: $result\n";
}
Jump to Line
Something went wrong with that request. Please try again.