On Thu, 2003-10-23 at 10:21, Jeff Borders wrote:
> Hello,
> 
> I'm a total newbie with only a few programs under my belt.  Anyway, I
> would like to create a command line calculator.  Like the one available
> in python.
> 
> The python interpreter will accept 5+5 or 5 + 5.


Perl will as well... here's a simple perl calculator... 

##############################################################
#!perl

use strict;

$| = 1;

while (1) {
  print "Please enter your expression (or 'exit' to exit): ";
  chomp(my $cmd = <>);
  exit if ($cmd =~ /^\s*exit\s*$/);

  my $result = eval "$cmd";
  print "Result = $result\n\n";
}
##############################################################



> 
> I would like some ideas on how to parse the command line.  I can read it
> in as STDIN, but then need to determine the two or more numbers and the
> operators.
> 
> Thanks.
> 
> Jeff Borders


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to