Perl as a pocket calculator 
Author Message
 Perl as a pocket calculator

Needing a calculator program the other day and not having anything like
bc available, I wrote a simple 6 line perl script that evaled and printed
each of its input lines.  After playing with it for a while, I noticed
that it all could be done very simply from the command line like so:

perl -pe "s/^.*$/eval $&/e;"

After I mentioned this to Larry he suggested using:


so any error messages would be printed out.  This is very useful
not only as a pocket calculator replacement, but as a tool for trying
perl stuff out when writing perl scripts.

--
Perl's Maternal Uncle
Mark Biggar



Fri, 01 Jan 1993 05:07:05 GMT  
 Perl as a pocket calculator
When running the one liner perl calculator described in
this group, I sometimes get a weird "bad free()" error:


sin(2)
0.90929742682568170942
sin(3.14159)
Bad free() ignored, <> line 2.
2.6535897933527261422e-0
^D
%

The system is a Sun Sparcstation-1 (4/60) running release 4.1
of Sun OS.  The Perl was release 3.0, patchlevel 18, compiled
with the standard Sun C compiler.  I can replicate the problem
on other Sun SPARC systems running 4.0.3 and 4.1 Sun OS,
but it does not occur on Sun-3 (68020 CPU) or VAX systems.

I suspect a bug in Sun OS or perl, but
I'm not sure where to look at this point.

Don Winsor
Department of Electrical Engineering and Computer Science
University of Michigan, Ann Arbor



Sun, 03 Jan 1993 00:39:22 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Perl on Pocket PC 2002?

2. perl/tk pocket reference

3. ? User Agent for Pocket IE ?

4. PHP pocket reference (book review)

5. HP-style calculator in perl

6. **Need Calculator Script*

7. How to optimize this? (a check-sum calculator)

8. Limited form of eval() - just a calculator

9. Date subroutines and calculator

10. gtkperl finacial calculator NEW!

11. Simple Permutation Calculator

12. financial calculator

 

 
Powered by phpBB® Forum Software