Month: January 2011

bash math

some quick links :

Enhanced by Zemanta

fork a new process in perl

I was doing something today and found that I require to fork a new process in perl. Now I had never done this earlier, so I did not know how to do this.

First some background :

I was doing some program very similar to http server, where the script accepts some input through a socket and then processes the same. In doing so I was seeing that the script was taking some time in processing the input and thus was not processing the second request until the first one was completed. Simple solution, fork the process.

[cc lang=”perl”]


if (! $fork)


do the child processing





do the parent processing



Enhanced by Zemanta

bash mathematical calculators.

To start with , the most simple and easy to use should be “bc”. but just for some guys who want to be more experimental, here are few more bash calulator programs. These are completely command line and thus you can completely integrate them in your shell script or use them in shell script to do some really crazy maths calculations.

sudo yum install calc clac

Lets start with installing these. Before we start, don’t blame and flame me if your favourite is not there in the list. If it is not, better is you drop me  a comment or email, and I will see, if I can include it in the list above, but remember this is only for console based calculators.

First clac:

Name        : clac                         Relocations: (not relocatable)
Version     : 005                               Vendor: Fedora Project
Release     : 1.fc14                        Build Date: Mon 23 Aug 2010 01:45:04 PM IST
Install Date: Tue 14 Dec 2010 03:10:50 PM IST      Build Host:
Group       : Applications/Engineering      Source RPM: clac-005-1.fc14.src.rpm
Size        : 13003                            License: GPLv3+
Signature   : RSA/SHA256, Mon 23 Aug 2010 09:52:32 PM IST, Key ID 421caddb97a1071f
Packager    : Fedora Project
URL         :
Summary     : Command Line Advanced Calculator
Description :
clac (Command Line Advanced Calculator) evaluates mathematical expressions
from the argument list or from stdin and writes the answer(s) to stdout.

clac is written in python, so anytime you want to get into python help, you can type


other than that for most of the math calculations, you can simply type the expression to get the result. And remember you can always do :

echo "8+3"|clac

and then calc:

Name        : calc                         Relocations: (not relocatable)
Version     :                          Vendor: Fedora Project
Release     : 14.fc12                       Build Date: Sat 25 Jul 2009 06:46:45 AM IST
Install Date: Tue 14 Dec 2010 03:10:52 PM IST      Build Host:
Group       : Applications/Engineering      Source RPM: calc-
Size        : 2601450                          License: GPLv2
Signature   : RSA/SHA256, Thu 29 Jul 2010 01:27:10 AM IST, Key ID 421caddb97a1071f
Packager    : Fedora Project
URL         :
Summary     : Arbitrary precision arithmetic system and calculator
Description :
Calc is an arbitrary precision C-like arithmetic system that is a
calculator, an algorithm-prototyper, and a mathematical research tool. Calc
comes with a rich set of built-in mathematical and programmatic functions.

Note: this copy of Calc is linked against the GNU Readline library and has
been converted to the ordinary GPL as per section 3 of the LGPL. See the
included calc-converted-to-gpl.txt document for details.

So far, calc is the only application where I see a prompt, “;”. other than that all the other functionalities remain the same. So, go ahead and enjoy spending some time in exploring these applications.