E-Mail:
Author Avatar

Perl Calculator

Perl Calculator

Most Linux systems installed with the distro defaults include perl. You probably

recognize perl from it’s widespread use in web applications. It does a great job

in that realm. But perl is also a nearly complete programming language. With
perl installed on your machine, you can take advantage of the full set of perl
math functions, all, of course, from the command line.

Today’s Tweak requires another modification to .bashrc. Simply add these two
lines:

    calc(){ perl -wlne’print eval’; }
    export -f calc

These two lines will allow you access to all perl’s math functions via the
‘eval’ argument.

So, what’s the use of today’s Tweak? Once you’ve written the lines into your
.bashrc file, you can see for yourself. Fire off the perl calculator with the
command calc:

    tony@valhalla ~ $ calc
    6*6*6
    216

See it? This Tweak gives you the ability to calculate mathematical equations,
simple or complex, directly from the command line. You can exit with Ctrl+c.

Now, there’s no more need to open a GUI calculator or reach for one on your
desk. You’ve built everything you need into bash.

What Do You Think?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
Interview, Linux, Misc - Dec 19, 2007

KOffice vs OOXML: Practical, Not Political

Author Avatar
Myths - Dec 3, 2007

5 Myths That Stymie Linux Growth

Author Avatar
Just Ask Matt - Linux Edition - Nov 20, 2007

Default Sound Card Not Sticking In Ubuntu!