That's pretty cool, here's a simple calculator too ;-)
#!/usr/local/bin/perl -w
use strict; $|++; print "> ";
print eval, "\n> " while chomp( $_ = <STDIN> );
Enjoy!
--
Casey
| [reply] [d/l] [select] |
This can be done in a one-liner:
perl -ple '$_ = "> " . eval'
which you can add to your .bashrc file using:
alias calc='perl -ple '\''$_ = "> " . eval'\'''
You can exit the loop with ^D.
Remember: There's always one more bug.
| [reply] [d/l] [select] |
Here's one that takes its input from, and writes the results to, the Windows clipboard. It will process multiple lines independently, and will transform this: 49.99*1.175
(49.99*1.175)*5 into this:49.99*1.175 = 58.73825
(49.99*1.175)*5 = 293.69125 If you change the lines, copy them, and recalculate, then it will ignore anything after the = signs.
| [reply] |