Douglas A. Tutty <[EMAIL PROTECTED]>: > On Fri, Nov 14, 2008 at 07:11:23AM -0600, Ron Johnson wrote: > > On 11/14/08 06:46, Tzafrir Cohen wrote: > > >On Fri, Nov 14, 2008 at 12:25:27PM +0100, Fran?ois Cerbelle wrote: > > [snip] > > >>You should try "bc". I'm sure that you can type in everything you can type > > >>in your GUI based calculator. > > You can use python in a shell like bc with lots of power as well. > Different strokes.
Yup. #!/usr/bin/perl -w # # Usage: calcme <string_to_calculate> [<output_format>] # # Input is a string like (10+3)/7 or "(10 + 3) / 7" # Output is the calculated result of the string # Optional formatting can be supplied as 2nd parameter. # my ( $format, $calcme, $output ); if ( @ARGV == 0 || @ARGV > 2 ) { die( "Usage: $0 <\"formula_to_calculate\"> [<output_format>]\n: $!" ); } $format = ""; $calcme = $ARGV[0]; ( @ARGV == 2 ) && ( $format = $ARGV[1] ); $output = eval( $calcme ); if( @ARGV == 1 ) { print(STDOUT "$output\n"); } else { printf(STDOUT "$format\n", $output); } exit(0); __END__ # So there. :-) I do hope to learn python in the not too distant # future. -- Any technology distinguishable from magic is insufficiently advanced. (*) http://blinkynet.net/comp/uip5.html Linux Counter #80292 - - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]