<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-25125788</id><updated>2012-01-22T03:43:38.481-08:00</updated><title type='text'>Linux, Perl and Web development</title><subtitle type='html'>This blog has content related to Linux, Apache, MySQL, PHP, Perl, CSS, JavaScript and Free software/open source.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>91</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-25125788.post-2950946774244997606</id><published>2009-10-28T03:59:00.001-07:00</published><updated>2009-10-28T03:59:22.418-07:00</updated><title type='text'>Apache: .htaccess redirection</title><content type='html'>If you want visitors of your old website domain to be redirected to&lt;br&gt;the new domain, use the following code in .htaccess file placed in the&lt;br&gt;document root of your old website.&lt;p&gt;RewriteEngine On&lt;br&gt;RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]&lt;br&gt;RewriteRule ^(.*)$ &lt;a href="http://www.newdomain.com/$1"&gt;http://www.newdomain.com/$1&lt;/a&gt; [R=301,L]&lt;p&gt;This way, visitors of&lt;p&gt;&lt;a href="http://olddomain.com/some_file.html"&gt;http://olddomain.com/some_file.html&lt;/a&gt;&lt;br&gt;will be redirected to&lt;br&gt;&lt;a href="http://www.newdomain.com/some_file.html"&gt;http://www.newdomain.com/some_file.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-2950946774244997606?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/2950946774244997606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=2950946774244997606' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/2950946774244997606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/2950946774244997606'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/10/apache-htaccess-redirection.html' title='Apache: .htaccess redirection'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-494012951712694968</id><published>2009-08-05T22:41:00.001-07:00</published><updated>2009-08-05T22:41:42.716-07:00</updated><title type='text'>Linux: Avoid scp when copying a lot of files</title><content type='html'>When you are copying a lot of files files it may take a long time with&lt;br&gt;scp. This is because scp spawns a new process for each file and can be&lt;br&gt;resource intensive.&lt;p&gt;When using the -r switch, scp does not care about symbolic links and&lt;br&gt;will follow them, even if it has already copied the file. This can&lt;br&gt;lead to scp copying an infinite amount of data and can easily fill up&lt;br&gt;your hard disk.&lt;p&gt;Therefore, when you think of backups or remote copy of directories,&lt;br&gt;think of rsync.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-494012951712694968?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/494012951712694968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=494012951712694968' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/494012951712694968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/494012951712694968'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/08/linux-avoid-scp-when-copying-lot-of.html' title='Linux: Avoid scp when copying a lot of files'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-7620406761860559275</id><published>2009-08-05T03:04:00.001-07:00</published><updated>2009-08-05T03:04:53.154-07:00</updated><title type='text'>Linux: Download whole website with wget</title><content type='html'>Command to download whole website&lt;p&gt;wget -r -p -np -k &lt;a href="http://www.sonomamgmt.com"&gt;http://www.sonomamgmt.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-7620406761860559275?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/7620406761860559275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=7620406761860559275' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/7620406761860559275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/7620406761860559275'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/08/linux-download-whole-website-with-wget.html' title='Linux: Download whole website with wget'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1934380233195364218</id><published>2009-07-10T03:54:00.001-07:00</published><updated>2009-07-10T03:54:26.938-07:00</updated><title type='text'>Linux : Install fonts on Linux</title><content type='html'>To install new fonts in your home directory (only for you; not&lt;br&gt;system-wide) follow this procedure.&lt;p&gt;If ~/.fonts does not exist,&lt;br&gt;% mkdir ~/.fonts&lt;p&gt;Download and copy the .ttf files into this directory and run&lt;p&gt;% fc-cache&lt;p&gt;For users who need to download Devanagari fonts, here&amp;#39;s a good resource.&lt;br&gt;&lt;a href="http://www.wazu.jp/gallery/Fonts_Devanagari.html"&gt;http://www.wazu.jp/gallery/Fonts_Devanagari.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1934380233195364218?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1934380233195364218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1934380233195364218' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1934380233195364218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1934380233195364218'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/07/linux-install-fonts-on-linux.html' title='Linux : Install fonts on Linux'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1122482552963187457</id><published>2009-05-20T20:16:00.001-07:00</published><updated>2009-05-20T20:16:39.239-07:00</updated><title type='text'>MySQL:Set up unique key ignoring duplicates</title><content type='html'>For many of you who might be having trouble setting up a unique key on&lt;br&gt;a table containing duplicates, here&amp;#39;s the key&lt;p&gt;mysql&amp;gt; ALTER IGNORE TABLE table_name ADD UNIQUE(column_name)&lt;p&gt;Please note the keyword IGNORE in the above statement. That does the&lt;br&gt;work forcefully.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1122482552963187457?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1122482552963187457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1122482552963187457' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1122482552963187457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1122482552963187457'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/05/mysqlset-up-unique-key-ignoring.html' title='MySQL:Set up unique key ignoring duplicates'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-3503722891246977958</id><published>2009-02-15T20:39:00.001-08:00</published><updated>2009-02-15T20:39:30.231-08:00</updated><title type='text'>Linux : tr (translate) command</title><content type='html'>I made a good use of the translate command recently to get month-name&lt;br&gt;in upper case. I needed this in a shell script. Here&amp;#39;s the command&lt;p&gt;date +%b | tr [a-z] [A-Z]&lt;p&gt;Output: FEB&lt;p&gt;Learn more about tr using the following command&lt;p&gt;man tr&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-3503722891246977958?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/3503722891246977958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=3503722891246977958' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3503722891246977958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3503722891246977958'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/02/linux-tr-translate-command.html' title='Linux : tr (translate) command'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-7434085133120087494</id><published>2009-02-09T06:29:00.001-08:00</published><updated>2009-02-09T06:29:11.756-08:00</updated><title type='text'>Consider freelancing !</title><content type='html'>Reasons why you should consider freelancing&lt;p&gt;* Freelancing provides you with chances to build your own business&lt;br&gt;contacts who will keep you busy.&lt;br&gt;* You are free to do many jobs at the same time.&lt;br&gt;* Nobody takes away your credit. You get rewarded for your work.&lt;br&gt;* You can work remotely from the comfort of your home. You save daily&lt;br&gt;commute which takes a lot of time.&lt;br&gt;* You can work when you are most productive. Flexibility of time is a&lt;br&gt;great advantage.&lt;br&gt;* You get good pay rate simply because there are no overheads. Money&lt;br&gt;is not lost to company administration or your manager :-)&lt;br&gt;* As I started writing this post, I thought someone must have done it&lt;br&gt;before so I googled and found that there&amp;#39;s a list of 101 such reasons&lt;br&gt;on&lt;br&gt;&lt;a href="http://www.hrworld.com/features/101-reasons-to-freelance-091007/"&gt;http://www.hrworld.com/features/101-reasons-to-freelance-091007/&lt;/a&gt;&lt;br&gt;I never considered all those reasons before starting freelancing myself.&lt;br&gt;* Finally, because it&amp;#39;s become hard to get a job when the world is hit&lt;br&gt;by recession.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-7434085133120087494?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/7434085133120087494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=7434085133120087494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/7434085133120087494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/7434085133120087494'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/02/consider-freelancing.html' title='Consider freelancing !'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-3132860663869712238</id><published>2009-02-03T19:50:00.001-08:00</published><updated>2009-02-03T19:50:23.157-08:00</updated><title type='text'>Mysql: keep connection open for longer</title><content type='html'>These mysql queries will keep the connection open for 1800 seconds&lt;p&gt;SET @@local.wait_timeout=1800;&lt;br&gt;SET @@wait_timeout=1800;&lt;br&gt;SET @@local.interactive_timeout=1800;&lt;br&gt;SET @@interactive_timeout=1800;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-3132860663869712238?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/3132860663869712238/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=3132860663869712238' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3132860663869712238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3132860663869712238'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/02/mysql-keep-connection-open-for-longer.html' title='Mysql: keep connection open for longer'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-8796211266864840139</id><published>2009-01-28T23:05:00.001-08:00</published><updated>2009-01-28T23:05:51.415-08:00</updated><title type='text'>MySQL: GROUP BY on datetime column</title><content type='html'>SELECT DATE_FORMAT(MyDate, &amp;#39;%d %M %Y&amp;#39;) AS Date, COUNT(*) AS numRows&lt;br&gt;FROM Table1 GROUP BY Date;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-8796211266864840139?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/8796211266864840139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=8796211266864840139' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/8796211266864840139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/8796211266864840139'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2009/01/mysql-group-by-on-datetime-column.html' title='MySQL: GROUP BY on datetime column'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-4757501313172907152</id><published>2008-12-28T21:38:00.001-08:00</published><updated>2008-12-28T21:38:31.004-08:00</updated><title type='text'>Linux : Installing mplayer on centOS</title><content type='html'>Installing mplayer on centOS is simple ! Execute the following commands as root&lt;p&gt;&lt;br&gt;%  wget &lt;a href="http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm"&gt;http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm&lt;/a&gt;&lt;br&gt;%  wget &lt;a href="http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm"&gt;http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm&lt;/a&gt;&lt;br&gt;%  rpm --import &lt;a href="http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt"&gt;http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt&lt;/a&gt;&lt;br&gt;%  rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm&lt;br&gt;%  rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm&lt;br&gt;%  yum check-update&lt;br&gt;%  yum install mplayer&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-4757501313172907152?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/4757501313172907152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=4757501313172907152' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4757501313172907152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4757501313172907152'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2008/12/linux-installing-mplayer-on-centos.html' title='Linux : Installing mplayer on centOS'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-53666415713979359</id><published>2008-09-16T06:12:00.001-07:00</published><updated>2008-09-16T06:12:48.662-07:00</updated><title type='text'>Bash : concatenate strings in bash</title><content type='html'>The problem -&lt;p&gt;You have $yr=2008&lt;br&gt;You want to obtain something like 2008_data.csv etc&lt;p&gt;$yr_data.csv does not work&lt;p&gt;The solution - Use curly braces to separate variables from strings&lt;br&gt;like this&lt;p&gt;${yr}_data.csv&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-53666415713979359?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/53666415713979359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=53666415713979359' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/53666415713979359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/53666415713979359'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2008/09/bash-concatenate-strings-in-bash.html' title='Bash : concatenate strings in bash'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-4251587244968962255</id><published>2008-09-11T01:06:00.001-07:00</published><updated>2008-09-11T01:06:55.671-07:00</updated><title type='text'>Linux : setting up hostname</title><content type='html'>Here&amp;#39;s how you can set hostname of your linux machine&lt;p&gt;Become root, save hostname in /etc/hostname and tell the hostname&lt;br&gt;command to read the name from the file.&lt;br&gt;Here are the commands to do the same&lt;p&gt;% su&lt;br&gt;% echo your_hostname &amp;gt; /etc/hostname&lt;br&gt;% hostname -F /etc/hostname&lt;p&gt;However, on next reboot, hostname will be lost.&lt;p&gt;On Red Hat / centOS, edit HOSTNAME= entry of the file&lt;br&gt;/etc/sysconfig/network&lt;p&gt;This sets up the hostname permanently.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-4251587244968962255?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/4251587244968962255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=4251587244968962255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4251587244968962255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4251587244968962255'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2008/09/linux-setting-up-hostname.html' title='Linux : setting up hostname'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-3699820814621256426</id><published>2008-08-10T21:46:00.001-07:00</published><updated>2008-08-10T21:46:53.124-07:00</updated><title type='text'>MySQL : Delete all tables of a database</title><content type='html'>It seems there&amp;#39;s no command to delete all tables of a database. I have&lt;br&gt;been just dropping the database and creating it again. Does anyone&lt;br&gt;know any better method ? If you don&amp;#39;t have privileges to create/drop&lt;br&gt;db, my method is not going to work :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-3699820814621256426?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/3699820814621256426/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=3699820814621256426' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3699820814621256426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3699820814621256426'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2008/08/mysql-delete-all-tables-of-database.html' title='MySQL : Delete all tables of a database'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1881495609233420087</id><published>2008-02-01T06:13:00.001-08:00</published><updated>2008-02-01T06:13:04.703-08:00</updated><title type='text'>MySQL : grant command</title><content type='html'>The GRANT function is used both to create new users, and to assign privileges to users.&lt;br&gt;&lt;pre&gt;mysql&amp;gt;GRANT SELECT, INSERT, UPDATE, DELETE&lt;br&gt;    -&amp;gt;ON widgets.* TO widgetAdmin@localhost &lt;br&gt;    -&amp;gt;IDENTIFIED BY &amp;#39;ilovewidgets&amp;#39;;&lt;br&gt; &lt;/pre&gt; &lt;p&gt; Assuming that the user widgetAdmin did not yet exist when this query is executed, both the &lt;i&gt;user&lt;/i&gt; and &lt;i&gt;db&lt;/i&gt; tables will be updated with the necessary rows. &lt;/p&gt; The above is taken from &lt;a href="http://dev.mysql.com"&gt;dev.mysql.com&lt;/a&gt;.&lt;br&gt;&lt;br&gt;You can also use assign all privileges to a user on a certain database. Following is the syntax.&lt;br&gt;&lt;br&gt;mysql&amp;gt; GRANT ALL PRIVILEGES ON&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; test.* TO &amp;#39;ketan&amp;#39;@&amp;#39;localhost&amp;#39; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; IDENTIFIED BY &amp;#39;ketans_password&amp;#39;;&lt;br&gt;&lt;br&gt;I find this command exceedingly useful ! A quick way to set up privileges of a user on a db.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1881495609233420087?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1881495609233420087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1881495609233420087' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1881495609233420087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1881495609233420087'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2008/02/mysql-grant-command.html' title='MySQL : grant command'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1325771716546486589</id><published>2008-01-03T05:52:00.001-08:00</published><updated>2008-01-03T05:52:35.862-08:00</updated><title type='text'>PHP : Facebook application to solve jumbled words</title><content type='html'>Wrote a facebook application to solve jumbled words.&lt;p&gt;&lt;a href="http://apps.facebook.com/word_jumble/"&gt;http://apps.facebook.com/word_jumble/&lt;/a&gt;&lt;p&gt;Try it out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1325771716546486589?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1325771716546486589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1325771716546486589' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1325771716546486589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1325771716546486589'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2008/01/php-facebook-application-to-solve.html' title='PHP : Facebook application to solve jumbled words'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-3365482672193664614</id><published>2007-12-28T21:52:00.001-08:00</published><updated>2007-12-28T21:52:32.592-08:00</updated><title type='text'>PHP : Solve jumbled words</title><content type='html'>Wrote a facebook application to solve jumbled words. Here&amp;#39;s the link&lt;p&gt;&lt;a href="http://apps.facebook.com/word_jumble/"&gt;http://apps.facebook.com/word_jumble/&lt;/a&gt;&lt;p&gt;Enjoy !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-3365482672193664614?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/3365482672193664614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=3365482672193664614' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3365482672193664614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3365482672193664614'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/12/php-solve-jumbled-words.html' title='PHP : Solve jumbled words'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1357651153943635012</id><published>2007-12-12T10:38:00.001-08:00</published><updated>2007-12-12T10:38:13.407-08:00</updated><title type='text'>MySQL : rename a table</title><content type='html'>Renaming a table is easy ! Following is the command.&lt;p&gt;mysql&amp;gt; RENAME TABLE users TO members;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1357651153943635012?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1357651153943635012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1357651153943635012' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1357651153943635012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1357651153943635012'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/12/mysql-rename-table.html' title='MySQL : rename a table'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-2060427309606194536</id><published>2007-11-24T02:45:00.001-08:00</published><updated>2007-11-24T02:45:32.327-08:00</updated><title type='text'>Perl : selecting randomly elements of an array</title><content type='html'>&lt;span style="color: rgb(0, 102, 0);"&gt;#!/usr/bin/env perl&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;use strict;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; my @test = (0,1,2,3,4,5);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;my $i = 6;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;while($i &amp;gt; 0){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;my $offset = int(rand(scalar(@test)+1)) - 1;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print $test[$offset].&amp;quot;\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;splice(@test,$offset,1);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$i--;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; }&lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-2060427309606194536?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/2060427309606194536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=2060427309606194536' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/2060427309606194536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/2060427309606194536'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/11/perl-selecting-randomly-elements-of.html' title='Perl : selecting randomly elements of an array'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-284666560436909888</id><published>2007-10-13T05:43:00.001-07:00</published><updated>2007-10-13T05:43:15.141-07:00</updated><title type='text'>Perl : making all filenames lowercase</title><content type='html'>Renaming all files in a directory to lowercase names in a directory recursively.&lt;p&gt;find . -type f -exec perl -e &amp;#39;rename($_, lc) || warn &amp;quot;$_: $!\n&amp;quot; for @ARGV&amp;#39; {} \;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-284666560436909888?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/284666560436909888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=284666560436909888' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/284666560436909888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/284666560436909888'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/10/perl-making-all-filenames-lowercase.html' title='Perl : making all filenames lowercase'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-4892835411253416043</id><published>2007-09-12T08:46:00.001-07:00</published><updated>2007-09-12T08:46:30.950-07:00</updated><title type='text'>MySQL : root password reset</title><content type='html'>Here&amp;#39;s what you need to do in case you forget the root user password of mysql.&lt;p&gt;# stop mysql service&lt;br&gt;/etc/init.d/mysql stop&lt;p&gt;# Start to MySQL server w/o password&lt;br&gt;mysqld_safe --skip-grant-tables &amp;amp;&lt;p&gt;# Connect to mysql server using mysql client&lt;br&gt;mysql -u root&lt;p&gt;# Setup new MySQL root user password&lt;br&gt;mysql&amp;gt; use mysql;&lt;br&gt;mysql&amp;gt; update user set password=PASSWORD(&amp;quot;NEW-ROOT-PASSWORD&amp;quot;) where User=&amp;#39;root&amp;#39;;&lt;br&gt;mysql&amp;gt; flush privileges;&lt;br&gt;mysql&amp;gt; quit&lt;p&gt;# Stop MySQL Server&lt;br&gt;/etc/init.d/mysql stop&lt;p&gt;# Start MySQL server and test it&lt;br&gt;/etc/init.d/mysql start&lt;br&gt;mysql -u root -h localhost -p&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-4892835411253416043?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/4892835411253416043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=4892835411253416043' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4892835411253416043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4892835411253416043'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/09/mysql-root-password-reset.html' title='MySQL : root password reset'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1344997735680247300</id><published>2007-09-04T00:34:00.001-07:00</published><updated>2007-09-04T00:34:22.676-07:00</updated><title type='text'>Web Development : Saving sessions in database</title><content type='html'>Some advantages of saving sessions in database.&lt;p&gt;  1. The session data is more secure as a potential hacker must be&lt;br&gt;able to log into the database before he can access anything.&lt;br&gt;   2. The use of multiple servers would not create a problem as all&lt;br&gt;session data now resides in a single central place and is accessible&lt;br&gt;by all servers.&lt;br&gt;   3. It is much easier to query the database should the site&lt;br&gt;administrator require information about current sessions or current&lt;br&gt;users.&lt;p&gt;-- &lt;br&gt;Regards,&lt;br&gt;Ketan&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1344997735680247300?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1344997735680247300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1344997735680247300' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1344997735680247300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1344997735680247300'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/09/web-development-saving-sessions-in.html' title='Web Development : Saving sessions in database'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-3096864363792204159</id><published>2007-08-29T01:44:00.001-07:00</published><updated>2007-08-29T01:44:38.450-07:00</updated><title type='text'>Linux : setting up rdist</title><content type='html'>rdist command is very helpful in synchronizing filesystems on two&lt;br&gt;server. rdist stands for remote distribution. Many useful options are&lt;br&gt;available with the command.&lt;p&gt;See `man rdist` for more information about the command.&lt;p&gt;This is how I set up rdists :-)&lt;p&gt;My crontab entry&lt;br&gt;10 * * * * rdist -f $HOME/bin/rdist_file &amp;gt; /dev/null&lt;p&gt;###rdist_file contains&lt;p&gt;##  these are comments&lt;br&gt;/path/of/source/file -&amp;gt; target_server1 install&lt;br&gt;-onochkowner,nochkgroup,nochkmode /path/to/the/target/file;&lt;p&gt;###  file rdist ed to target_server2&lt;br&gt;/path/of/source/file -&amp;gt; target_server2 install&lt;br&gt;-onochkowner,nochkgroup,nochkmode /path/to/the/target/file;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-3096864363792204159?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/3096864363792204159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=3096864363792204159' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3096864363792204159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/3096864363792204159'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/08/linux-setting-up-rdist.html' title='Linux : setting up rdist'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-4977667297440339650</id><published>2007-08-29T01:22:00.001-07:00</published><updated>2007-08-29T01:22:05.406-07:00</updated><title type='text'>Linux : splitting a log file</title><content type='html'>To split a file into small files of 5000 lines, use this,&lt;p&gt;% split -l 5000 file&lt;p&gt;This creates files like xaa, xab etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-4977667297440339650?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/4977667297440339650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=4977667297440339650' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4977667297440339650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4977667297440339650'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/08/linux-splitting-log-file.html' title='Linux : splitting a log file'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-1101429882497484012</id><published>2007-08-23T00:36:00.001-07:00</published><updated>2007-08-23T00:36:55.009-07:00</updated><title type='text'>My website</title><content type='html'>I have launched my website.&lt;p&gt;&lt;a href="http://www.carvingIT.com"&gt;http://www.carvingIT.com&lt;/a&gt;.&lt;p&gt;Your feedback is welcome !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-1101429882497484012?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/1101429882497484012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=1101429882497484012' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1101429882497484012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/1101429882497484012'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/08/my-website.html' title='My website'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-4453030280442414882</id><published>2007-08-09T22:20:00.001-07:00</published><updated>2007-08-09T22:20:25.401-07:00</updated><title type='text'>Leaving my job</title><content type='html'>After working with ANSYS-Fluent Inc. for more than 7 years, I have&lt;br&gt;decided to start working as a Consultant in the field of Linux,&lt;br&gt;Apache, MySQL, Perl/PHP. After joining Fluent, I developed liking for&lt;br&gt;the Linux platform and the open source technologies.&lt;p&gt;During my tenure with Fluent, I wrote many complex perl scripts and&lt;br&gt;modules. Now, I think Open Source is the field where I can help the&lt;br&gt;community and grow individually as well.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-4453030280442414882?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/4453030280442414882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=4453030280442414882' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4453030280442414882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/4453030280442414882'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/08/leaving-my-job.html' title='Leaving my job'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-5539245705192159211</id><published>2007-05-14T01:46:00.001-07:00</published><updated>2007-05-14T01:46:38.236-07:00</updated><title type='text'>html source and bandwidth usage</title><content type='html'>1 character equals 1 byte.&amp;nbsp; Extra newline in html source means one extra byte sent to client. &lt;br clear="all"&gt;If a website gets some 400 pageviews per day, you send 400x30 (sligtly more than 1 Kb) extra bytes per month.&lt;br&gt;  This means 1 character may mean 1 Kb of bandwidth usage per month for a website of low traffic. More the traffic more the size associated per character.&lt;br&gt; &lt;br&gt; Therefore, to save the bandwidth and to improve loading speed of your pages, optimize your templates and html !&lt;br&gt; &lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-5539245705192159211?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/5539245705192159211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=5539245705192159211' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/5539245705192159211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/5539245705192159211'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/05/html-source-and-bandwidth-usage.html' title='html source and bandwidth usage'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-7953216012287531662</id><published>2007-02-28T01:14:00.001-08:00</published><updated>2007-02-28T01:14:47.931-08:00</updated><title type='text'>mod_perl : DBI.so/GD.so can't be loaded</title><content type='html'>mod_perl can not load modules like DBI.so or GD.so ? The reason this happens is that the perl version with which you compiled mod_perl may not be the same that you are using currently. Whenever you upgrade perl, you have to recompile mod-perl and may be re-install these modules. That may solve this problem.&lt;br clear="all"&gt;&lt;br&gt; If you are using Apache2, you are lucky in the sense that you won&amp;#39;t have to compile apache with mod_perl. Just re-build perl and install it and then build mod_perl and install.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-7953216012287531662?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/7953216012287531662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=7953216012287531662' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/7953216012287531662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/7953216012287531662'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/02/modperl-dbisogdso-cant-be-loaded.html' title='mod_perl : DBI.so/GD.so can&apos;t be loaded'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116946993339840288</id><published>2007-01-22T04:45:00.000-08:00</published><updated>2007-02-11T23:09:31.420-08:00</updated><title type='text'>PHP : Handling multiple select menu</title><content type='html'>Thought of putting a code to illustrate handling multiple select menus with php.&lt;br /&gt;&lt;br /&gt;Note the square brackets and the multiple="multiple" part in the form.&lt;br /&gt;&lt;br /&gt;HTML form&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;lt;form action="some_action_file.php" method="post"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;select name="select_name[]" multiple="multiple"&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;lt;option value="a"&amp;gt;a&amp;lt;/option&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;lt;option value="b"&amp;gt;b&amp;lt;/option&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;lt;option value="c"&amp;gt;c&amp;lt;/option&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; &amp;lt;option value="d"&amp;gt;d&amp;lt;/option&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;/select&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;input type="submit" value="Submit" /&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;br /&gt;PHP part&lt;br /&gt;----------&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;?php&lt;/span&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;## some_action_file.php&lt;/span&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;foreach ($_POST['select_name'] as $select_name){&lt;/span&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;echo "$select_name&amp;lt;br /&amp;gt;"; ## prints all the selected values; one per line&lt;/span&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;?&amp;gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116946993339840288?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116946993339840288/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116946993339840288' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116946993339840288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116946993339840288'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/01/php-handling-multiple-select-menu.html' title='PHP : Handling multiple select menu'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116892484395175476</id><published>2007-01-15T21:20:00.000-08:00</published><updated>2007-01-15T21:20:43.996-08:00</updated><title type='text'>Perl : Removing last newline in while</title><content type='html'>Here&amp;#39;s a way to check if we are at the last iteration and removing the newline if true, while iterating through lines.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;while(&amp;lt;&amp;gt;){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chomp if eof;&lt;span style="color: rgb(153, 102, 51);"&gt; ### eof returns 1 if next read on filehandle returns end of file&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print; &lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt;&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116892484395175476?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116892484395175476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116892484395175476' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116892484395175476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116892484395175476'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/01/perl-removing-last-newline-in-while.html' title='Perl : Removing last newline in while'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116798594784407916</id><published>2007-01-05T00:32:00.000-08:00</published><updated>2007-01-05T00:32:28.123-08:00</updated><title type='text'>Perl : Locating a perl module file</title><content type='html'>How do you find out exactly where a perl module file is ? Following example searches &lt;a href="http://template.pm/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"&gt;Template.pm&lt;/a&gt; in the paths where perl modules are installed.&lt;br&gt;  &lt;br&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;find `perl -e &amp;#39;$,=&amp;quot;\n&amp;quot;;print @INC&amp;#39;` -name &lt;a href="http://template.pm/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"&gt;Template.pm&lt;/a&gt;&lt;/span&gt; &lt;br clear="all"&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Note&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;The perl command is in back-ticks. This is an example of command execution within a command.&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;   &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116798594784407916?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116798594784407916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116798594784407916' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116798594784407916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116798594784407916'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/01/perl-locating-perl-module-file.html' title='Perl : Locating a perl module file'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116798066221242935</id><published>2007-01-04T23:04:00.000-08:00</published><updated>2007-01-04T23:04:22.266-08:00</updated><title type='text'>Networking : Switches versus Hubs</title><content type='html'>A few days back, I replaced hub with a switch in my small LAN at home. Although it&amp;#39;s just a plug and play sort of switch, I had to do some configuration changes so that computers could ping each other. I spent a lot of time solving connectivity problems :-) Learnt a lot about how switches work in the process.&lt;br&gt; &lt;br&gt; I can think of following differences between a hub and a switch.&lt;br&gt; &lt;br&gt; 1. Hub requires no knowledge of how it works. It&amp;#39;s easy to install. The same is not true with switches. Even if the manual s&lt;br&gt; ays &amp;quot;plug and play switch&amp;quot;, it&amp;#39;s better to know how switches work.&lt;br&gt; &lt;br&gt; 2. You may have to configure your NICs (network cards) so that the switch communicates. To configure network cards, you need&lt;br&gt; &amp;nbsp;to learn what to configure.&lt;br&gt; &lt;br&gt; 3. Switches offer you a learning opportunity :-). In the process of making your network work for you, you&amp;#39;ll learn people me&lt;br&gt; an by words like duplex auto-negotiation and speed.&lt;br&gt; &lt;br&gt; 4. If you are required to troubleshoot, you learn still more. In that case, you&amp;#39;ll learn commands like ethtool, ifconfig, tr&lt;br&gt; aceroute, ifup, ifdown etc.&lt;br&gt; &lt;br&gt; 5. Conlusion is, Switches are better than hubs not only because of the reasons you read on the net, but they also teach you&lt;br&gt; networking.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116798066221242935?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116798066221242935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116798066221242935' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116798066221242935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116798066221242935'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2007/01/networking-switches-versus-hubs.html' title='Networking : Switches versus Hubs'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116583923378072330</id><published>2006-12-11T04:13:00.000-08:00</published><updated>2006-12-11T04:13:55.056-08:00</updated><title type='text'>Linux : renaming files with rename in a loop</title><content type='html'>Following command (a small shell script) changes file extensions of all files from .TXT to .txt in the working directory.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;for file in `find . -type f -name &amp;quot;*.TXT&amp;quot;`; do rename .TXT .txt $file; done&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;The above works in bash. For use in other shells, you'll have to change the looping sytax.&lt;/span&gt;&lt;br&gt; &lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116583923378072330?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116583923378072330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116583923378072330' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116583923378072330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116583923378072330'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/12/linux-renaming-files-with-rename-in.html' title='Linux : renaming files with rename in a loop'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116427807650133922</id><published>2006-11-23T02:34:00.000-08:00</published><updated>2006-11-23T02:34:37.303-08:00</updated><title type='text'>Perltidy</title><content type='html'>Perltidy is a great utility for formatting your perl codes. It splits long lines into short lines, does formatting with blocks thus increasing the readability of your codes. You can save your own settings related to formatting in a file called .perltidyrc. This file should saved in $HOME directory.&lt;br&gt; &lt;br&gt; For more information and download of Perltidy, visit&lt;br&gt; &lt;a href="http://perltidy.sourceforge.net/"&gt;http://perltidy.sourceforge.net/&lt;/a&gt;&lt;br clear="all"&gt;&lt;br&gt; Perltidy is coool !&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116427807650133922?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116427807650133922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116427807650133922' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116427807650133922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116427807650133922'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/perltidy.html' title='Perltidy'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116401137865870859</id><published>2006-11-20T00:29:00.000-08:00</published><updated>2006-11-20T00:29:39.693-08:00</updated><title type='text'>Linux : Killing processes</title><content type='html'>Sometimes you have to kill several processes generated by a service/server (the main process) and killing one process is not enough. Recently, I had trouble with 'apachectl stop'. This would not stop all the processes of httpd for some strange reason. Killing all processes by entering the process id's would take quite some time. I figured a way out -&lt;br&gt; &lt;br&gt; Here's the time-saver&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;ps -ef | grep httpd | awk '//{print $2}' | xargs kill&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt;You can use the same logic for other processes. You need to replace httpd with ..... you know. As you can see, awk separates just the process ids and it becomes easier for us to kill the processes !&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116401137865870859?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116401137865870859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116401137865870859' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116401137865870859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116401137865870859'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/linux-killing-processes.html' title='Linux : Killing processes'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116399923234734323</id><published>2006-11-19T21:07:00.000-08:00</published><updated>2006-11-19T21:07:12.390-08:00</updated><title type='text'>Perl : Is this module Installed ?</title><content type='html'>How do you check if a certain perl module is installed and is in @INC ?&lt;br&gt; &lt;br&gt; On the command-line, issue this command&lt;br&gt; &lt;br style="color: rgb(102, 102, 0);"&gt; &lt;span style="color: rgb(102, 102, 0);"&gt;perl -e 'use X::Y'&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;X&lt;span style="color: rgb(0, 0, 0);"&gt;::Y is the module&lt;br&gt; With -e, you can executes the perl code in quotes on command line.&lt;br&gt; &lt;/span&gt;&lt;/span&gt;&lt;br&gt; If the module is found, there won't be any errors (no output).&lt;br&gt;&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116399923234734323?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116399923234734323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116399923234734323' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116399923234734323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116399923234734323'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/perl-is-this-module-installed.html' title='Perl : Is this module Installed ?'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116375872404490919</id><published>2006-11-17T02:18:00.000-08:00</published><updated>2006-11-17T02:18:44.086-08:00</updated><title type='text'>Perl : Generating password with a subroutine</title><content type='html'>A subroutine to generate a password :-) When you find it hard to create one.&lt;br&gt; &lt;br clear="all"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;sub generatePassword&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;{&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $passwd_size = shift;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; my @alphanum = ('a'..'z', 'A'..'Z', 0..9,'!','#','$','%','&amp;amp;','*','@','`');&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $password = join '', map $alphanum[rand @alphanum], 0..$passwd_size;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $password;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;Usage&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;amp;generatePassword(10);&lt;/span&gt; ### returns password of 10 chars&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116375872404490919?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116375872404490919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116375872404490919' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116375872404490919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116375872404490919'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/perl-generating-password-with.html' title='Perl : Generating password with a subroutine'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116350698415179225</id><published>2006-11-14T04:23:00.000-08:00</published><updated>2006-11-16T23:47:22.336-08:00</updated><title type='text'>Perl : Installing CPAN modules</title><content type='html'>This post if for those who find it hard or don't know how to install CPAN modules.&lt;br /&gt;&lt;br /&gt;1 Become root&lt;br /&gt;&lt;br /&gt;2. Run&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;perl -MCPAN -e shell&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First time you run this command, you'll be asked some questions regarding where to download/extract files etc. Just select the defaults.&lt;br /&gt;&lt;br /&gt;3. This opens the cpan prompt. Now, run&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;install Module::Name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That's all you have to do. Isn't this really simple ?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116350698415179225?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116350698415179225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116350698415179225' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116350698415179225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116350698415179225'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/perl-installing-cpan-modules.html' title='Perl : Installing CPAN modules'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116330108053758024</id><published>2006-11-11T19:11:00.000-08:00</published><updated>2006-11-11T19:11:20.603-08:00</updated><title type='text'>osix.net : A good website for programmers</title><content type='html'>I would like everybody to know I am a registered user of &lt;a href="http://www.osix.net"&gt;www.osix.net&lt;/a&gt;. There, I have cleared Geek Level 6 from the &amp;quot;Geek Challenge&amp;quot;. These levels are programming puzzles on solving which you earn some reward points. You can exchange these reward points for hints from other geeks (experts), creating polls,&amp;nbsp; email address or pop access to email. There are some other redemption possibilities.&lt;br clear="all"&gt;&lt;br&gt; A great site for geeks !&lt;br&gt; &lt;br&gt; My profile there&lt;br&gt; &lt;a href="http://www.osix.net/modules/viewprofile/?name=ketan404"&gt;http://www.osix.net/modules/viewprofile/?name=ketan404&lt;/a&gt;&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116330108053758024?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116330108053758024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116330108053758024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116330108053758024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116330108053758024'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/osixnet-good-website-for-programmers.html' title='osix.net : A good website for programmers'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116238303833777145</id><published>2006-11-01T04:10:00.000-08:00</published><updated>2006-11-01T04:10:38.383-08:00</updated><title type='text'>Perl : use Tie::File</title><content type='html'>With Tie::File module you can read all lines of a file in an array. Updating array elements updates the corresponding lines in the file. This is more efficient than reading the whole file, doing replacements and writing it back.&lt;br&gt; &lt;br&gt; Following code snippet is an example&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;use Tie::File;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;tie @line_array, 'Tie::File', 'file' or die &amp;quot;Can not tie file:$!&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;for (@line_array) {&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s/pattern/replacement/g;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### or do anything that you wish to&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### updating elements of array will update corresponding lines in the tied file&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### pushing an element will add a line &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;untie @line_array;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; Tie::File is very efficient for updating large files.&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116238303833777145?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116238303833777145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116238303833777145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116238303833777145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116238303833777145'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/11/perl-use-tiefile.html' title='Perl : use Tie::File'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116229313469374587</id><published>2006-10-31T03:12:00.000-08:00</published><updated>2006-10-31T03:12:15.560-08:00</updated><title type='text'>Linux : Virtual Memory Statistics</title><content type='html'>vmstat command shows Virtual Memory Statistics. &lt;br&gt; &lt;br&gt; Sample outputs of the command are shown below.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;$ vmstat&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;r&amp;nbsp; b&amp;nbsp;&amp;nbsp; swpd&amp;nbsp;&amp;nbsp;&amp;nbsp; free&amp;nbsp;&amp;nbsp;&amp;nbsp; buff&amp;nbsp;&amp;nbsp;&amp;nbsp; cache&amp;nbsp;&amp;nbsp; si&amp;nbsp;&amp;nbsp; so&amp;nbsp;&amp;nbsp;&amp;nbsp; bi&amp;nbsp;&amp;nbsp; bo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in&amp;nbsp; cs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; us&amp;nbsp; sy&amp;nbsp; id&amp;nbsp;&amp;nbsp; wa&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;0&amp;nbsp; 0 507912&amp;nbsp; 6016&amp;nbsp; 5216&amp;nbsp; 61768&amp;nbsp;&amp;nbsp; 0 &amp;nbsp; &amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; 98&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br&gt; With -s option (this prints the vm table)&lt;br&gt; &lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;$ vmstat -s&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 515420&amp;nbsp; total memory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 510060&amp;nbsp; used memory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 340984&amp;nbsp; active memory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 18404&amp;nbsp; inactive memory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5360&amp;nbsp; free memory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5580&amp;nbsp; buffer memory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 62024&amp;nbsp; swap cache&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1024088&amp;nbsp; total swap&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 507896&amp;nbsp; used swap&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 516192&amp;nbsp; free swap&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5159612 non-nice user cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 284811 nice user cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1343974 system cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 441240715 idle cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1061329 IO-wait cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 266848 IRQ cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 130451 softirq cpu ticks&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 135296968 pages paged in&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 21489954 pages paged out&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 402670 pages swapped in&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 414068 pages swapped out&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 402061903 interrupts&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 401831289 CPU context switches&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp; 1157798489 boot time&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 185206 forks&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;br clear="all"&gt;To get just one number say that of free memory, you have to pipe this command to a awk (or perl or some other) that does filtering.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;$ vmstat -s | awk '/free memory/{print $1}'&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;5360&lt;/span&gt;&lt;br&gt;&lt;br&gt; awk is sometimes handier than grep :-)&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116229313469374587?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116229313469374587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116229313469374587' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116229313469374587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116229313469374587'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/10/linux-virtual-memory-statistics.html' title='Linux : Virtual Memory Statistics'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116218492477416537</id><published>2006-10-29T21:08:00.000-08:00</published><updated>2006-10-29T21:08:44.830-08:00</updated><title type='text'>PHP : variable names by form fields</title><content type='html'>Here's a quick way to make form fields accessible just by appending a $ sign as in old php3.&lt;br&gt; Notice the two $ signs.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;foreach ($_POST as $key=&amp;gt;$val)&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;{&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;$$key=$val;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br clear="all"&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116218492477416537?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116218492477416537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116218492477416537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116218492477416537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116218492477416537'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/10/php-variable-names-by-form-fields.html' title='PHP : variable names by form fields'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-116036877069184221</id><published>2006-10-08T21:39:00.000-07:00</published><updated>2006-10-08T21:39:30.733-07:00</updated><title type='text'>Linux : Finding unique types of files</title><content type='html'>Here's a quick way to figure out what different file-types (based on extension) you have. The following example checks the working directory. A hash of extensions is used in the perl code that appears in single quotes.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;find . -name &amp;quot;*.*&amp;quot; | perl -e 'while(&amp;lt;&amp;gt;){$ext{$1}++ if(/\.([\w]+)$/);} $,=&amp;quot;\n&amp;quot;; print sort keys %ext;'&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;Do you find this useful ?&lt;/span&gt;&lt;br&gt; &lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-116036877069184221?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/116036877069184221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=116036877069184221' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116036877069184221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/116036877069184221'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/10/linux-finding-unique-types-of-files.html' title='Linux : Finding unique types of files'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115889879810894926</id><published>2006-09-21T21:19:00.000-07:00</published><updated>2006-09-21T21:19:58.180-07:00</updated><title type='text'>Linux : Changing ownership with find command</title><content type='html'>Good example of find with -exec...&lt;br&gt; &lt;br&gt; Following command finds all files under &lt;span style="color: rgb(153, 102, 51);"&gt;/var/www/html&lt;/span&gt; owned by user &lt;span style="color: rgb(153, 102, 51);"&gt;ketan&lt;/span&gt; and changes the owner and group to &lt;span style="color: rgb(153, 102, 51);"&gt; webuser&lt;/span&gt; and &lt;span style="color: rgb(153, 102, 51);"&gt;web&lt;/span&gt; respectively. Only root can do this.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;find /var/www/html -user ketan -exec chown webuser:web {} \;&lt;br&gt; &lt;br&gt; &lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115889879810894926?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115889879810894926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115889879810894926' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115889879810894926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115889879810894926'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/09/linux-changing-ownership-with-find.html' title='Linux : Changing ownership with find command'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115865797805368684</id><published>2006-09-19T02:26:00.000-07:00</published><updated>2006-09-19T02:26:18.106-07:00</updated><title type='text'>Documentation with Pod</title><content type='html'>&lt;span style="color: rgb(0, 102, 0);"&gt;Pod&lt;/span&gt; is a simple-to-use markup language used for writing documentation for Perl, Perl programs, and Perl modules. POD stands for &lt;span style="color: rgb(153, 102, 51);"&gt;Plain Old Documentation &lt;/span&gt;. Pod documentation can be included in perl scripts or modules.&lt;br&gt; &lt;br&gt; Translators are available for converting Pod to various formats like plain text, HTML, man pages, and more.&lt;br&gt; &lt;br&gt; Following commands are supported&lt;br&gt; &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(0, 102, 0);"&gt;=head1 Heading Text&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =head2 Heading Text&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =head3 Heading Text&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =head4 Heading Text&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =over indentlevel&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =item stuff&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =back&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =cut&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =pod&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =begin format&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =end format&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =for format text&lt;/span&gt;&lt;br&gt; &lt;br&gt; Following is an example of a pod document. To test, copy the following part into a file and run &lt;span style="font-style: italic; color: rgb(153, 102, 51);"&gt;perldoc filename&lt;/span&gt;.&lt;br&gt; &lt;br&gt; #######################################&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;=head1 NAME&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;abc.pl&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;=head1 DESCRIPTION&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;This line shows up as description. This line shows up as description. This line shows up as description. This line shows up as description.&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;=head1 USAGE&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;I&amp;lt; perl abc.pl &amp;gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;The script asks for 3 inputs. They are -&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;* x&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;* y&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;* z&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;=head2 heading2&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;Try this out ! You may want to include documentation of your scripts in Pod.&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;=head1 AUTHOR&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ketan404&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;=cut&lt;/span&gt;&lt;br&gt; ###############&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115865797805368684?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115865797805368684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115865797805368684' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115865797805368684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115865797805368684'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/09/documentation-with-pod.html' title='Documentation with Pod'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115622687395105194</id><published>2006-08-21T23:07:00.000-07:00</published><updated>2006-08-21T23:07:54.603-07:00</updated><title type='text'>Linux : find and replace with grep and sed</title><content type='html'>Following command finds PATTERN and replaces it with REPLACEMENT in all files under directory/path/.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;grep -rl PATTERN directory/path/ | xargs sed -i 's/PATTERN/REPLACEMENT/g'&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes :&lt;br&gt; &lt;br&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;-r&lt;/span&gt; option of grep does recursive search&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;-i&lt;/span&gt; option of sed edits files in place&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;g&lt;/span&gt; does substitutions in all occurences&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br&gt; &lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115622687395105194?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115622687395105194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115622687395105194' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115622687395105194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115622687395105194'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/08/linux-find-and-replace-with-grep-and.html' title='Linux : find and replace with grep and sed'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115573355644378416</id><published>2006-08-16T06:05:00.000-07:00</published><updated>2006-08-16T06:05:56.490-07:00</updated><title type='text'>Bash : Saving time with Environment Variables</title><content type='html'>You can create an environment variable $dr (for document_root) to save typing the whole path /var/www/html.&lt;br&gt; &lt;br&gt; In your &lt;span style="color: rgb(153, 102, 51);"&gt;.bashrc&lt;/span&gt; file add this line&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;export dr=/var/www/html&lt;/span&gt;&lt;br&gt; &lt;br&gt; Then source .bashrc. After this you'll be able to use shortcuts like&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;vi $dr/index.htm&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt; With export, we create a new environment variable. In c shell, the syntax is &lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;setenv dr /var/www/html&lt;/span&gt;&lt;br&gt; &lt;br&gt; You can see all the environment variables with &lt;span style="color: rgb(153, 102, 51);"&gt;env&lt;/span&gt;.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115573355644378416?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115573355644378416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115573355644378416' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115573355644378416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115573355644378416'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/08/bash-saving-time-with-environment.html' title='Bash : Saving time with Environment Variables'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115527789059907729</id><published>2006-08-10T23:31:00.000-07:00</published><updated>2006-08-10T23:31:30.646-07:00</updated><title type='text'>Perl : Regular Expression to match an email address</title><content type='html'>Following regular expression matches a valid email address&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;/^(\w|\-|\_|\.)+\@((\w|\-|\_)+\.)+[a-zA-Z]{2,}$/&lt;/span&gt;&lt;br&gt; &lt;br&gt; To learn more about regular expressions in Perl, read &lt;br&gt; &lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;man perlre&lt;br&gt; &lt;br clear="all"&gt; &lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115527789059907729?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115527789059907729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115527789059907729' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115527789059907729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115527789059907729'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/08/perl-regular-expression-to-match-email.html' title='Perl : Regular Expression to match an email address'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115519356945402815</id><published>2006-08-10T00:06:00.000-07:00</published><updated>2006-08-10T00:12:32.863-07:00</updated><title type='text'>Linux : find files, find patterns and replace in one go</title><content type='html'>&lt;span class="gmail_quote"&gt;&lt;/span&gt;Following command finds all text file in current working directory and replaces XYZ with ABC in all found files.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;find . -name "*.txt" -exec perl -pe 's/XYZ/ABC/g' -i {} \;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Notes&lt;br /&gt;&lt;/span&gt; &lt;ul&gt;   &lt;li&gt;You need to have perl installed on your system&lt;/li&gt;   &lt;li&gt;with &lt;span style="color: rgb(153, 102, 51);"&gt;-exec&lt;/span&gt; you can execute a command on the found files&lt;br /&gt;  &lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;-i&lt;/span&gt; option of perl is used to update files&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;-p&lt;/span&gt; option of perl command assumes a loop around the code just like the &lt;span style="color: rgb(153, 102, 51);"&gt;-n&lt;/span&gt; switch. Only difference is that it prints the lines. &lt;/li&gt;   &lt;li&gt;XYZ is a regular expression to be searched and ABC is the replacement text.&lt;br /&gt;  &lt;/li&gt; &lt;/ul&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115519356945402815?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115519356945402815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115519356945402815' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115519356945402815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115519356945402815'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/08/linux-find-files-find-patterns-and.html' title='Linux : find files, find patterns and replace in one go'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115441901402382978</id><published>2006-08-01T00:56:00.000-07:00</published><updated>2006-08-01T00:56:54.100-07:00</updated><title type='text'>Fwd: Back after many days !</title><content type='html'>Hi !&lt;br&gt; &lt;div&gt; &lt;br&gt; I am back after many days of inactivity.&lt;br&gt; &lt;/div&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115441901402382978?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115441901402382978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115441901402382978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115441901402382978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115441901402382978'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/08/fwd-back-after-many-days.html' title='Fwd: Back after many days !'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115390269731317334</id><published>2006-07-26T01:28:00.000-07:00</published><updated>2006-07-26T01:31:37.326-07:00</updated><title type='text'>PHP : Getting image size</title><content type='html'>&lt;span style="font-family: arial;font-size:100%;" &gt;PHP has a very handy function getimagesize() which returns an array of values like width, height, type etc.&lt;br /&gt;&lt;br /&gt;    Example&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;$image_size = getimagesize("path/to/the&lt;wbr&gt;/image.jpg"); ## URLs can also be passed &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 0);"&gt;$image_size[0]&lt;/span&gt; is the width and &lt;span style="color: rgb(102, 102, 0);"&gt;$image_size[1]&lt;/span&gt; is the height of the image.&lt;br /&gt;&lt;br /&gt;    You can also use the following line (picked from &lt;a href="http://php.net/" title="http://php.net (http://php.net/) (http://php.net/) (http://php.net/)" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"&gt;php.net&lt;/a&gt;) so as to get the values in four different variables directly with the use of list() function.&lt;br /&gt;&lt;br /&gt;&lt;code style="color: rgb(0, 102, 0);"&gt;&lt;span&gt;&lt;span&gt;list(&lt;/span&gt;&lt;span&gt;$width&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;$height&lt;/span&gt;&lt;span&gt;, &lt;/span&gt; &lt;span&gt;$type&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;$attr&lt;/span&gt;&lt;span&gt;) = &lt;/span&gt;&lt;span&gt;getimagesize&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt; "img/flag.jpg"&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115390269731317334?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115390269731317334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115390269731317334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115390269731317334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115390269731317334'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/07/php-getting-image-size_26.html' title='PHP : Getting image size'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115333829242017131</id><published>2006-07-19T12:44:00.000-07:00</published><updated>2006-07-19T12:44:52.506-07:00</updated><title type='text'>Linux : Appending a tar file with xargs</title><content type='html'>Whereas -c switch of tar command creates an archive, -r is used to append files to a tar files. In the following example, xargs keeps on sending htm files as input to the tar command. These files are appended to htm_files.tar.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;find . -name &amp;quot;*.htm&amp;quot; | xargs tar rvf htm_files.tar&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt;Usual way of tar -cvf does not work for the above purpose.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115333829242017131?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115333829242017131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115333829242017131' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115333829242017131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115333829242017131'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/07/linux-appending-tar-file-with-xargs.html' title='Linux : Appending a tar file with xargs'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115311728217816852</id><published>2006-07-16T23:21:00.000-07:00</published><updated>2006-07-16T23:21:22.253-07:00</updated><title type='text'>Linux : Find and Rename files with -exec</title><content type='html'>Following command finds .html files in the current working directory and changes the extension to .htm. The command illustrates the use of rename with find's exec switch. A quick way of finding and renaming files.&lt;br&gt; &lt;br clear="all"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;find . -name &amp;quot;*.html&amp;quot; -exec rename .html .htm {} \;&lt;/span&gt;&lt;br&gt;&lt;br&gt; Find is regarded as a power command by many Linux users. The above example supports the claim ! There are many seemingly complicated or time consuming tasks which can be done quickly with commands. &lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115311728217816852?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115311728217816852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115311728217816852' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115311728217816852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115311728217816852'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/07/linux-find-and-rename-files-with-exec.html' title='Linux : Find and Rename files with -exec'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115260195706463905</id><published>2006-07-11T00:12:00.000-07:00</published><updated>2006-07-11T00:12:37.130-07:00</updated><title type='text'>Linux : Counting files per directory with Bash command</title><content type='html'>With commands, you can do many intricate things. Following command which is a small script, counts the number of .htm files in each subdirectory upto depth 2 of the current working directory.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;for x in `find . -type d -maxdepth 2`; do y=`find $x -name &amp;quot;*.htm&amp;quot; | wc -l`; if [ $y != 0 ]; then echo $x - $y; fi done&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt; This command is useful for webmasters who spend some time once in a while to figure out number of files in each of the website's subdirectories.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes&lt;/span&gt;&lt;br&gt; &lt;ol&gt;   &lt;li&gt;The value of &lt;span style="color: rgb(153, 102, 51);"&gt;-maxdepth&lt;/span&gt; may be changed as needed&lt;/li&gt;   &lt;li&gt;The above command uses current directory (find . -type ...). The dot may be replaced by path of a directory of which the stats is needed.&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;&amp;quot;*.htm&amp;quot;&lt;/span&gt; part of the filename may also be replaced with whatever you want &lt;/li&gt; &lt;/ol&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115260195706463905?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115260195706463905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115260195706463905' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115260195706463905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115260195706463905'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/07/linux-counting-files-per-directory.html' title='Linux : Counting files per directory with Bash command'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115218134878093443</id><published>2006-07-06T03:22:00.000-07:00</published><updated>2006-07-06T03:22:28.833-07:00</updated><title type='text'>Perl : Obfuscation of ARGV</title><content type='html'>Did you know ?&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$a=eval shift @{$x.=chr for qw * 65 82 71 86 * ;$x};&lt;/span&gt;&lt;br clear="all"&gt;&lt;br&gt; is just another way of saying&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$a = shift @ARGV;&lt;/span&gt;&lt;br&gt; &lt;br&gt; Same thing can be done in many different ways. And some ways are intended at making it hard for humans to grasp the code ! Read more about &lt;a href="http://en.wikipedia.org/wiki/Obfuscated_code"&gt;Code obfuscation&lt;/a&gt;.&lt;br&gt; &lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115218134878093443?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115218134878093443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115218134878093443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115218134878093443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115218134878093443'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/07/perl-obfuscation-of-argv.html' title='Perl : Obfuscation of ARGV'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115164816262387377</id><published>2006-06-29T23:16:00.000-07:00</published><updated>2006-06-29T23:16:02.680-07:00</updated><title type='text'>Perl : Formatting code</title><content type='html'>&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Following one liner attempts to format your codes. Works on programs of perl, c, php etc where curly braces - '{ and }', are used for blocks, loops, conditions etc.&lt;/span&gt;&lt;br&gt; &lt;br&gt; perl -pe '$tabs = substr($tabs,1) if (/^\s*}\s*$/);s/^\s*/$tabs/;$tabs.=&amp;quot;\t&amp;quot; if(/{[^}]*$/);' -i.bk&lt;/span&gt; &lt;span style="font-style: italic; color: rgb(153, 102, 51);"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;filename.c &lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Files are backed up with &lt;span style="color: rgb(153, 102, 51);"&gt;.bk&lt;/span&gt; extension.&lt;br&gt; &lt;br&gt; Wildcards are allowed so &lt;span style="color: rgb(153, 102, 51);"&gt;*.c&lt;/span&gt; can be used in place of &lt;span style="color: rgb(153, 102, 51);"&gt;filename.c&lt;/span&gt;.&lt;br&gt; &lt;/span&gt;&lt;/span&gt;&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115164816262387377?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115164816262387377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115164816262387377' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115164816262387377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115164816262387377'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/perl-formatting-code.html' title='Perl : Formatting code'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115138452411366005</id><published>2006-06-26T22:02:00.000-07:00</published><updated>2006-06-26T22:02:04.166-07:00</updated><title type='text'>Perl : Editing files on the command line</title><content type='html'>With &lt;span style="color: rgb(153, 102, 51);"&gt;-i&lt;/span&gt; switch of perl, files can be edited on command line. You can optionally take a back-up of the old files by providing an extension.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;perl -pe 's/\r\n/\n/;' -i &lt;span style="font-style: italic;"&gt;file1&lt;/span&gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; Replaces &lt;span style="color: rgb(153, 102, 51);"&gt;\r\n&lt;/span&gt; (dos newlines) to &lt;span style="color: rgb(153, 102, 51);"&gt;\n&lt;/span&gt; from file1.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;perl -pe 's/\&amp;lt;\?php/&amp;lt;?/;' -i.bk *.php&lt;/span&gt;&lt;br&gt; &lt;br&gt; Replaces &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;lt;?php&lt;/span&gt; with &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;lt;?&lt;/span&gt; in php files and creates back-up files with .bk extension.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115138452411366005?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115138452411366005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115138452411366005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115138452411366005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115138452411366005'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/perl-editing-files-on-command-line.html' title='Perl : Editing files on the command line'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115104535570975166</id><published>2006-06-22T23:49:00.000-07:00</published><updated>2006-06-22T23:49:15.793-07:00</updated><title type='text'>vi/vim : Changing the tabsize</title><content type='html'>Default tabstop is 8. To set the tabsize to 4 spaces, just issue this command&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(51, 102, 102);"&gt;:set ts=4&lt;/span&gt;&lt;br&gt; &lt;br&gt; ts stands for &lt;span style="color: rgb(153, 102, 51);"&gt;tabstop&lt;/span&gt;.&lt;br&gt; &lt;br&gt; To make this a default setting, write this line without the colon ':' in .exrc (.vimrc if you use vim) file.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115104535570975166?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115104535570975166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115104535570975166' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115104535570975166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115104535570975166'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/vivim-changing-tabsize.html' title='vi/vim : Changing the tabsize'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115088081986756351</id><published>2006-06-21T02:06:00.000-07:00</published><updated>2006-06-21T02:06:59.926-07:00</updated><title type='text'>Vim : Dictionary completion facility</title><content type='html'>Dictionary completion facility is useful when you don't remember the spelling of a word. To make use of this, we must first set the dictionary option so that vim knows where the dictionary is. Following command does that.&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;:set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words&lt;/span&gt;&lt;br&gt; &lt;br&gt; Now, start typing a word in insert mode.&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;astro&amp;lt;ctrl+x&amp;gt;&amp;lt;ctrl+k&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; This shows the first match in the dictionary. You can loop through the matches by using &lt;span style="color: rgb(153, 102, 51);"&gt;&amp;lt;ctrl+n&amp;gt;&lt;/span&gt; (for next) and&lt;span style="color: rgb(153, 102, 51);"&gt; &amp;lt;ctrl+p&amp;gt;&lt;/span&gt;  (for previous).&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes&lt;/span&gt;&lt;br&gt; &lt;br&gt; To understand why the -= and +=, use this command&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;:help :set+=&lt;/span&gt;&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115088081986756351?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115088081986756351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115088081986756351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115088081986756351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115088081986756351'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/vim-dictionary-completion-facility.html' title='Vim : Dictionary completion facility'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115080283152786371</id><published>2006-06-20T04:27:00.000-07:00</published><updated>2006-06-20T04:27:11.593-07:00</updated><title type='text'>Regular Expressions : Dealing with special characters like asterisk</title><content type='html'>This post is for beginners of perl/regular expressions who find it hard to deal with special characters like asterisks if they appear in patterns. For instance, here is a pattern that contains an asterisk &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;4*3&lt;/span&gt;&lt;br&gt; If you want to replace or remove the asterisk, you will have to escape it with a back-slash ('\') in a regular expression. Following is a sample code.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$x = &amp;quot;4*3&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print &amp;quot;$x\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br&gt; ## following line removes the special character asterisk from the scalar $x&lt;br&gt; ## note that the asterisk is 'escaped' by using a back-slash&lt;br&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;$x =~ s/\*//;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br&gt; print &amp;quot;$x\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Output&lt;br&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;&lt;br&gt; 4*3&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;43&lt;br&gt; &lt;br style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;Use of a back-slash ('\') for escaping special characters is common where regular expressions are used. It's also used for escaping spaces in directory-names on shell prompt.&lt;br&gt; &lt;br&gt; Some examples&lt;br&gt; &lt;br&gt; character : escaping it&lt;br&gt; \ : \\&lt;br&gt; * : \*&lt;br&gt; + : \+&lt;br&gt; / : \/&lt;br&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115080283152786371?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115080283152786371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115080283152786371' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115080283152786371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115080283152786371'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/regular-expressions-dealing-with.html' title='Regular Expressions : Dealing with special characters like asterisk'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115079761603112251</id><published>2006-06-20T03:00:00.000-07:00</published><updated>2006-06-20T03:02:51.016-07:00</updated><title type='text'>Perl : Removing blank lines from a file</title><content type='html'>You can do intricate things even on command line. The following command prints filename on the command standard output after removing blank lines&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;cat &lt;span style="font-style: italic; color: rgb(153, 102, 51);"&gt;filename&lt;/span&gt;  | perl -ne 's/^\s*\n$//; print;'&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes&lt;/span&gt;&lt;br&gt; &lt;ul&gt;   &lt;li&gt;Replace &lt;span style="font-style: italic;"&gt;filename&lt;/span&gt; with the path of the file from which you want to remove blank lines.&lt;/li&gt;   &lt;li&gt;You can optionally redirect the output by using '&amp;gt;' operator to create a new file.&lt;br&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115079761603112251?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115079761603112251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115079761603112251' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115079761603112251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115079761603112251'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/perl-removing-blank-lines-from-file.html' title='Perl : Removing blank lines from a file'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-115017985183566109</id><published>2006-06-12T23:24:00.000-07:00</published><updated>2006-06-12T23:24:13.203-07:00</updated><title type='text'>Linux : Installing Packages .... common procedure</title><content type='html'>This post is for novices who are scared of building/installing new packages on linux :-) Here are the steps.&lt;br&gt; &lt;br&gt; &lt;ol&gt;   &lt;li&gt;Download the package. It's normally a .tar.gz file. It could be in some other format like bz2 as well.&lt;/li&gt;   &lt;li&gt;Extract it with&lt;span style="color: rgb(0, 102, 0);"&gt; tar -zxvf package.tar.gz&lt;/span&gt; (for .tar.gz files)&lt;br&gt;   &lt;/li&gt;   &lt;li&gt;Change to the newly created directory with this extraction&lt;/li&gt;   &lt;li&gt;Read README files (good practice)&lt;/li&gt;   &lt;li&gt;Run on prompt&lt;br&gt;     &lt;span style="color: rgb(0, 102, 0);"&gt;./confgure&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;then&lt;br&gt;     &lt;span style="color: rgb(0, 102, 0);"&gt;make&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;Become root if you have not already. Default location of installation of almost all new packages is &lt;span style="color: rgb(153, 102, 51);"&gt;/usr/local&lt;/span&gt; so you need write permission to create any new files there. &lt;/li&gt;   &lt;li&gt;issue&lt;br&gt;     &lt;span style="color: rgb(0, 102, 0);"&gt;make install&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; You can install packages in other locations by using &lt;span style="color: rgb(153, 102, 51);"&gt;--prefix=/path/where/you/want/to/install&lt;/span&gt; option to ./configure. Learn more about options by using --help (normally) switch of ./configure scripts. All configure scripts may not present you with nice help. &lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-115017985183566109?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/115017985183566109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=115017985183566109' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115017985183566109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/115017985183566109'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/linux-installing-packages-common.html' title='Linux : Installing Packages .... common procedure'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114924159025641450</id><published>2006-06-02T02:46:00.000-07:00</published><updated>2006-06-02T02:46:30.340-07:00</updated><title type='text'>Linux : Synchronizing directories with rdist</title><content type='html'>rdist is a linux command for keeping identical copies of directories/files over two hosts. File permissions and modification time are preserved if possible. It can use various protocols like ssh, rsh (default). You can have all the synchronization details stored in a file and pass the filename as an argument with option -f to the command as illustrated below.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;rdist -f rdist_file&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;To specify the protocol, use -P option&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;rdist -P /usr/bin/ssh -f rdist_file&lt;/span&gt;&lt;br&gt; &lt;br clear="all"&gt;rdist_file is of the following format.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;## comments start with '#' sign&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;/path/on/master/server&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp;&amp;nbsp; remote_server_name&amp;nbsp; install&amp;nbsp; /path/on/slave/server ;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; -o option is used for specifying an action to be taken on those files on the slave (remote server) which are missing from the master. For truly synchromising two directlries, you can use -oremove to remove the files. The directive then takes the following form.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;/path/on/master/server&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp;&amp;nbsp; remote_server_name&amp;nbsp; install -oremove /path/on/slave/server ;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;For more about actions and about the command, see man pages.&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114924159025641450?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114924159025641450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114924159025641450' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114924159025641450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114924159025641450'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/06/linux-synchronizing-directories-with.html' title='Linux : Synchronizing directories with rdist'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114907345261499915</id><published>2006-05-31T04:04:00.000-07:00</published><updated>2006-05-31T04:04:12.693-07:00</updated><title type='text'>Linux : crontab does not run perl scripts ?</title><content type='html'>Recently, I had hard time making crontab run my perl script. The problem was with the environment variable PATH. When given correct path, it started executing the scripts. Following could be the problems&lt;br&gt; &lt;br&gt; &lt;ul&gt;   &lt;li&gt;Wrong shebang path (the first line that starts with #!). This line tells which command/program to use for execution of the script.&lt;/li&gt;   &lt;li&gt;Incorrect permissions&lt;br&gt;   &lt;/li&gt; &lt;/ul&gt; If you want to execute a perl script, make sure the output of 'which perl' is used as the path in your &lt;span style="color: rgb(153, 102, 51);"&gt;shebang&lt;/span&gt;.&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114907345261499915?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114907345261499915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114907345261499915' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114907345261499915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114907345261499915'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/05/linux-crontab-does-not-run-perl.html' title='Linux : crontab does not run perl scripts ?'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114836722210933083</id><published>2006-05-22T23:53:00.000-07:00</published><updated>2006-05-22T23:53:42.186-07:00</updated><title type='text'>Away for quite some time</title><content type='html'>I'm perturbed by Governments resolution to increase the quot for OBC by 27 %. &lt;span style="font-weight: bold;"&gt;My own view&lt;/span&gt; is that reservations, if any, should be based on economic status and not on caste or religion. Does the Indian Government want to divide the society ?&lt;br&gt; &lt;br&gt; I hope to be back for posting relevant content soon.&lt;br&gt; &lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114836722210933083?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114836722210933083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114836722210933083' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114836722210933083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114836722210933083'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/05/away-for-quite-some-time.html' title='Away for quite some time'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114749739620114737</id><published>2006-05-12T22:16:00.000-07:00</published><updated>2006-05-12T22:16:36.286-07:00</updated><title type='text'>PHP : Website Security</title><content type='html'>&lt;p class="mobile-post"&gt;PHP files that do database inserts or some other server-side tasks,&lt;br /&gt;should not be accessible via a web browser. All files under Document&lt;br /&gt;Root of a website are accessible by a web-browser. Document Root is&lt;br /&gt;the directory on the server's filesystem. This directory contains the&lt;br /&gt;files/web pages of the website.&lt;/p&gt;&lt;p class="mobile-post"&gt;To avoid direct access of your php files, you can keep them in a&lt;br /&gt;directory that is not inside Document Root. These files can then be&lt;br /&gt;included into your templates. For web applications, a configuration&lt;br /&gt;file can be included in all files using a relative path. This&lt;br /&gt;configuration file may contain variables like database connection&lt;br /&gt;details and other configuration variables. Include for database&lt;br /&gt;connection too, should reside outside the Document Root.&lt;/p&gt;&lt;p class="mobile-post"&gt;Variables of help&lt;/p&gt;&lt;p class="mobile-post"&gt;$_SERVER['DOCUMENT_ROOT']&lt;br /&gt;This followed by relative path of your conf or include files can be&lt;br /&gt;used on most servers.&lt;/p&gt;&lt;p class="mobile-post"&gt;On shared hosting server, Document Root is not defined for each&lt;br /&gt;website (virtual host), so this variable shows the default value. In&lt;br /&gt;such cases, you can use&lt;/p&gt;&lt;p class="mobile-post"&gt;dirname(__FILE__)&lt;/p&gt;&lt;p class="mobile-post"&gt;This gives you the value of the directory containing the file.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114749739620114737?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114749739620114737/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114749739620114737' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114749739620114737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114749739620114737'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/05/php-website-security.html' title='PHP : Website Security'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114680593060582568</id><published>2006-05-04T22:12:00.000-07:00</published><updated>2006-05-04T22:12:10.690-07:00</updated><title type='text'>Regular Expressions : Removing blank lines of a file in vi</title><content type='html'>In this post, I'm going to show you how blank lines of a file can be removed in vi editor with Regular Expressions.&lt;br&gt; &lt;br&gt; Following is an ex editor command.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;:1,$g/^$/d&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes :&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;ul&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;ex&lt;/span&gt; editor commands start with a colon.&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;1,$&lt;/span&gt; stands for first line to last line of the file&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;g&lt;/span&gt; for global (look for the pattern following everywhere; do not stop after the first match)&lt;/li&gt;   &lt;li&gt;pattern to look for is placed inside two slashes (&lt;span style="color: rgb(153, 102, 51);"&gt;//&lt;/span&gt;)&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;^&lt;/span&gt; is for start of line and $ for end of line. Here, there's nothing between the two so the pattern is used for an empty line&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;d&lt;/span&gt; in the end is the command to delete matching lines.&lt;/li&gt; &lt;/ul&gt; This regular expression does not match a line if it contains spaces. If you want to remove those lines as well, here's the modified command.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;:1,$g/^ *$/d&lt;/span&gt;&lt;br&gt; &lt;br&gt; Note that there's an asterisk (*) after a space. An asterisk matches the character preceeding it zero or more times.&lt;br&gt; e.g.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;/a*/&lt;/span&gt; matches a,aa,aaa,any number of times.&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;/\d*/&lt;/span&gt; mathes an integer. \d is for a digit.&lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114680593060582568?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114680593060582568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114680593060582568' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114680593060582568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114680593060582568'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/05/regular-expressions-removing-blank.html' title='Regular Expressions : Removing blank lines of a file in vi'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114672741488572798</id><published>2006-05-04T00:23:00.000-07:00</published><updated>2006-05-04T00:23:34.963-07:00</updated><title type='text'>Linux : music compositions with sox</title><content type='html'>Recently, I created a small web application in php and javascript for Tabla compositions. For those who don't know ... Tabla is a percussion instrument. Currently, it is in its primitive stage. By the way, &lt;a href="http://www.artists-india.com/tabla-editor/"&gt;here&lt;/a&gt; is the link to it.&lt;br&gt; &lt;br&gt; I'd like to take it further and add functionality which will allow merging of wav files with sox command that comes with linux distributions. This will allow composer to download his composition in wave format and hear it ! This will require reading the text file and mergin the sound files in the same order. This should be possible with a script (perl/php ?). &lt;br&gt; &lt;br&gt; I'll soon be collecting .wav recordings of all the basic tabla bols (aksharas) and give it a try. Your comments or ideas are welcome.&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114672741488572798?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114672741488572798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114672741488572798' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114672741488572798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114672741488572798'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/05/linux-music-compositions-with-sox.html' title='Linux : music compositions with sox'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114655328959635838</id><published>2006-05-02T00:01:00.000-07:00</published><updated>2006-05-02T00:01:29.673-07:00</updated><title type='text'>Linux : date command</title><content type='html'>&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(51, 0, 51);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Following are some illustrations of the date command.&lt;/span&gt;&lt;br&gt; &lt;br&gt; date&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;# This prints the current date. Something of this form - &amp;quot;Tue Jan 31 12:16:53 IST 2006&amp;quot;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date +%d&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;# prints current day of the month&lt;/span&gt;&lt;br&gt; &lt;br&gt; Following examples illustrate getting time related information of a day/date other than the current date&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date --date=&amp;quot;3 days ago&amp;quot;&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;# prints date that was 3 days ago&lt;/span&gt;&lt;br&gt; &lt;br&gt; Try these too !&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date --date=&amp;quot;last Sunday&amp;quot;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date --date=&amp;quot;next Sunday&amp;quot;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date --date=&amp;quot;Jan 26, 2004&amp;quot; +%a&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;# prints Day of the week on Jan 26, 2004&lt;/span&gt;&lt;br&gt; &lt;br&gt; Setting the system date. You need to have admin privileges to use --set option.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date --set='+10 minutes'&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;# Takes system clock forwad by 10 minutes.&lt;/span&gt;&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114655328959635838?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114655328959635838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114655328959635838' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114655328959635838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114655328959635838'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/05/linux-date-command.html' title='Linux : date command'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114621737127724471</id><published>2006-04-28T02:42:00.000-07:00</published><updated>2006-04-28T02:42:51.353-07:00</updated><title type='text'>Perl : What are Regular Expressions, by the way ?</title><content type='html'>A regular expression describes a set of strings, according to certain syntax rules.&lt;br&gt; &lt;br&gt; In this post, I just want to give beginners an idea. The topic 'Regular Expressions' is quite big. Unix commands - grep and sed were the first to popularize the concept. Many programming language support regular expressions for string manipulation. Perl has a powerful regex engine. The support/use of regular expressions gives Perl very powerful text-processing capabilities.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;man perlre&lt;/span&gt; gives you access to a man page dedicated to regular expressions and their use in Perl. Beginners, mastering regular expressions is the key to excelling in Perl programming !&lt;br clear="all"&gt;&lt;br&gt; Enjoy regular expressions :-)&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114621737127724471?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114621737127724471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114621737127724471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114621737127724471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114621737127724471'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-what-are-regular-expressions-by.html' title='Perl : What are Regular Expressions, by the way ?'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114620196688672698</id><published>2006-04-27T22:26:00.000-07:00</published><updated>2006-04-27T22:26:06.963-07:00</updated><title type='text'>Perl : Executing one line codes on the command line</title><content type='html'>Small codes of perl can be executed on command line with -e switch. The code is contained in single quotes. Following is an&lt;br&gt; example.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Command :&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;perl -e ' $\=&amp;quot; &amp;quot;; for (1 .. 9) { print; } '&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Output :&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;1 2 3 4 5 6 7 8 9&lt;/span&gt;&lt;br&gt; &lt;br&gt; Another frequently used switch is &lt;span style="color: rgb(153, 102, 51); font-weight: bold;"&gt;-n&lt;/span&gt;. This switch assumes '&lt;span style="color: rgb(153, 102, 51);"&gt;while(&amp;lt;&amp;gt;){...}&lt;/span&gt;' around your code. Useful for processing all lines of the input coming through pipes. Example follows. &lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Command :&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ls -l | perl -ne ' print if(/^d/); '&lt;/span&gt;&lt;br&gt; &lt;br&gt; Here, output of ls -l (long listing) is piped to the perl command. -n makes the code loop over all the lines of the input that come from the previous command. The regular expression checks if the lines start with the letter d. Thus the code prints details of only the directories contained in the working directory. The command is equivalent to &lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ls -l | perl -e ' while(&amp;lt;&amp;gt;){ print if(/^d/); } '&lt;/span&gt;&lt;br&gt; (without -n switch)&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;&lt;span style="font-weight: bold;"&gt;-a&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;is autosplit mode&lt;/span&gt;&lt;/span&gt; with -n or -p (&lt;span style="color: rgb(153, 102, 51);"&gt;splits $_ into @F &lt;/span&gt;). See how it works&lt;br&gt;  &lt;br&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;ls -l | perl -ane ' print $F[0].&amp;quot;\t&amp;quot;.$F[7].&amp;quot;\n&amp;quot;; '&lt;/span&gt;&lt;br&gt;  &lt;br&gt;  This prints the 0th and the 7th fields of the long directory listing (output of ls -l).&lt;br&gt; &lt;br&gt; You can learn more about switches with this command&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;perl -h&lt;/span&gt;&lt;br&gt; &lt;br&gt; To see version, built and other license related info,&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;perl -v&lt;/span&gt;&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114620196688672698?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114620196688672698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114620196688672698' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114620196688672698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114620196688672698'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-executing-one-line-codes-on.html' title='Perl : Executing one line codes on the command line'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114611448944379394</id><published>2006-04-26T22:08:00.000-07:00</published><updated>2006-04-26T22:08:09.526-07:00</updated><title type='text'>Perl : Sorting a list/array</title><content type='html'>Sorting of a list/array can be done with sort function. Reversing the order is easy; done with the function reverse. See following code and the output. &lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Code :&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@fruit = (&amp;quot;banana&amp;quot;,&amp;quot;mango&amp;quot;,&amp;quot;apple&amp;quot;);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@sorted_fruit = sort @fruit;&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;$,=&amp;quot; &amp;quot;; &lt;span style="color: rgb(153, 102, 51);"&gt;# $, is the output field separator (a predefined variable). This is used here to put spaces after printing every element of the array.&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$\=&amp;quot;\n&amp;quot;; &lt;span style="color: rgb(153, 102, 51);"&gt;# $\ is the output record separator. Used to add a newline to print in this example.&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;  &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br&gt; print @sorted_fruit;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print reverse @sorted_fruit; &lt;span style="color: rgb(153, 102, 51);"&gt;# reverses the order in the list&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="font-weight: bold;"&gt;Output :&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;apple banana mango&lt;br&gt; mango banana apple&lt;/span&gt;&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114611448944379394?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114611448944379394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114611448944379394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114611448944379394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114611448944379394'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-sorting-listarray.html' title='Perl : Sorting a list/array'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114606349126280795</id><published>2006-04-26T07:58:00.000-07:00</published><updated>2006-04-26T07:58:11.350-07:00</updated><title type='text'>This Blog : Conventions I use</title><content type='html'>&lt;p class="mobile-post"&gt;Hi !&lt;/p&gt;&lt;p class="mobile-post"&gt;This post does not have any code :-) Relief.&lt;/p&gt;&lt;p class="mobile-post"&gt;Wanted to make you aware of the conventions I have been following.&lt;br /&gt;You'll observe that green color is for the code. Comments are preceded&lt;br /&gt;by a '#' sign. This is because codes of perl, shell scripts and php&lt;br /&gt;use # for commenting. You'll find commented code in brown (well&lt;br /&gt;mostly; I may miss out on a few occasions). I'll also use the same&lt;br /&gt;brown color for [key]words worth noting. Your suggestions in this&lt;br /&gt;regard are welcome.&lt;/p&gt;&lt;p class="mobile-post"&gt;Feel free to share this blog with your friends. I believe this blog is&lt;br /&gt;shaping into a good learning resource. If you wish to have posts on a&lt;br /&gt;particular subject, let me know. I'll be more than happy to help you&lt;br /&gt;as much as I can.&lt;/p&gt;&lt;p class="mobile-post"&gt;You'll see some more Perl code snippets in the coming posts.&lt;br /&gt;Thanks for your patience.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114606349126280795?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114606349126280795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114606349126280795' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114606349126280795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114606349126280795'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/this-blog-conventions-i-use.html' title='This Blog : Conventions I use'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114603904995192081</id><published>2006-04-26T01:10:00.000-07:00</published><updated>2006-04-26T01:10:50.106-07:00</updated><title type='text'>Perl : 'Hello World !' and some more</title><content type='html'>This post is for those who want to start learning Perl. Save the following line in a file called 'hello.pl'. You can start learning Perl from the following example codes&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print &amp;quot;hello world !&amp;quot;;&lt;/span&gt;&lt;br&gt; &lt;br&gt; and run it with&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;perl hello.pl&lt;/span&gt;&lt;br&gt; &lt;br&gt; That's it ! It shows the output on the console.&lt;br&gt; &lt;br&gt; Some more code with comments follows. You may save this in another file and run it with perl command.&lt;br&gt; Comments begin with a #.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Code :&lt;/span&gt;&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$name = &amp;quot;ketan404&amp;quot;; &lt;span style="color: rgb(153, 102, 51);"&gt;## a scalar. Note the $ sign. It's good to use my while variable declarations but we shall cover that la&lt;/span&gt;&lt;/span&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;ter.&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@fruits = (&amp;quot;apple&amp;quot;,&amp;quot;banana&amp;quot;,&amp;quot;mango&amp;quot;); &lt;span style="color: rgb(153, 102, 51);"&gt;## this is an array. On the right side of the '=' sign is a list. Note the @ sign. &lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;%fruit_prices = (&amp;quot;apple&amp;quot;=&amp;gt;4,&amp;quot;banana&amp;quot;=&amp;gt;1,&amp;quot;mango&amp;quot;=&amp;gt;10); &lt;span style="color: rgb(153, 102, 51);"&gt;## this is called a hash. Names of the fruits are its keys and thier p &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;rices the values.&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;## printing these&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print $name.&amp;quot;\n&amp;quot;; &lt;span style="color: rgb(153, 102, 51);"&gt;## print the scalar and concatenate a newline to it. A dot (.) is used for concatenation.&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt;  &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print @fruits; &lt;span style="color: rgb(153, 102, 51);"&gt;## works ! print can also take an array as an argument.&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print @fruits.&amp;quot;\n&amp;quot;; &lt;span style="color: rgb(153, 102, 51);"&gt;## Oops ! You appended a newline to it ? Using @fruits in scalar context gives the number of elements in &lt;/span&gt;&lt;/span&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;the array and thus prints 3 with a newline. You'll understand these things as you make progress :-)&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;## printing keys and values of a hash&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;foreach $k (keys %fruit_prices){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print $k.&amp;quot;=&amp;gt;&amp;quot;.$fruit_prices{$k}.&amp;quot;\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;} &lt;span style="color: rgb(153, 102, 51);"&gt;## works as expected&lt;br&gt; ## keys function returns an array of keys of a hash. &lt;br&gt; ## foreach or for are used for traversing an array&lt;br&gt; &lt;/span&gt;&lt;/span&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114603904995192081?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114603904995192081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114603904995192081' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114603904995192081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114603904995192081'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-hello-world-and-some-more.html' title='Perl : &apos;Hello World !&apos; and some more'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114603335137481261</id><published>2006-04-25T23:35:00.000-07:00</published><updated>2006-04-25T23:35:51.453-07:00</updated><title type='text'>PHP : Object Oriented Programming in PHP</title><content type='html'>Object oriented programming is the use of objects to represent functional parts of an application. With php too, you can do object oriented programming to reduce and simplify the code. Following code is an example of the use of a php class.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Code :&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;?php&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;class web_developer{&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var $skills; &lt;span style="color: rgb(153, 102, 51);"&gt;# class variables&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var $sal;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function web_developer($sal){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;sal=$sal;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function getSal(){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $this-&amp;gt;sal;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function addSkill($technology,$yrs){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;skills[$technology]=$yrs;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function getSkills(){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $this-&amp;gt;skills;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;} &lt;span style="color: rgb(153, 102, 51);"&gt;# class ends here&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$x=new web_developer(2000); &lt;span style="color: rgb(153, 102, 51);"&gt;# creating a web_developer (an object) with associated salary !&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;echo $x-&amp;gt;getSal().&amp;quot;&amp;lt;br /&amp;gt;&amp;quot;;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;# retrieving a property (sal) of the object &lt;/span&gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;$x-&amp;gt;addSkill('php',5); &lt;span style="color: rgb(153, 102, 51);"&gt;# adding his skill-set and no. of years of experience&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$x-&amp;gt;addSkill('perl',4);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$x_skills=$x-&amp;gt;getSkills();&lt;span style="color: rgb(153, 102, 51);"&gt;# retrieving the property (skills) of the object&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br style="color: rgb(0, 102, 0);" clear="all"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;foreach ($x_skills as $k =&amp;gt; $v){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;echo &amp;quot;$k - $v&amp;lt;br /&amp;gt;&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;?&amp;gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Output in a browser:&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;2000&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;php - 5&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;perl - 4&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114603335137481261?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114603335137481261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114603335137481261' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114603335137481261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114603335137481261'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/php-object-oriented-programming-in-php.html' title='PHP : Object Oriented Programming in PHP'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114598179342783103</id><published>2006-04-25T09:16:00.000-07:00</published><updated>2006-04-25T19:00:02.070-07:00</updated><title type='text'>New on this Blog : Subscription by Email</title><content type='html'>&lt;p class="mobile-post"&gt;Hello readers !&lt;br /&gt;&lt;br /&gt;You might have noticed that I have added a form on the right for  email subscriptions. Don't be afraid. I'm not going to fill your inboxes with emails :-) If you find the content on this blog useful and would like to be notified about the new posts, consider filling out the form. I shall send you email notification manually from my gmail account since I don't have an account with any mass-emailing website.&lt;/p&gt;&lt;p class="mobile-post"&gt;Enjoy Perl for some time now !&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114598179342783103?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114598179342783103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114598179342783103' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114598179342783103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114598179342783103'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/new-on-this-blog-subscription-by-email.html' title='New on this Blog : Subscription by Email'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114596052590875196</id><published>2006-04-25T03:22:00.000-07:00</published><updated>2006-04-25T03:22:05.966-07:00</updated><title type='text'>Perl : map() with your subroutines</title><content type='html'>You can use map function with your subroutines as well. Have a look at the following example.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Code:&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;## subroutine that returns double of a number (or whatever passed to it as an argument :-)&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;sub double_it{&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2*$_;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@nums = (1 .. 10); &lt;span style="color: rgb(153, 102, 51);"&gt;# array containing numbers 1 to 10&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@doubles = map(&amp;amp;double_it, @nums); &lt;span style="color: rgb(153, 102, 51);"&gt;## using map to create @doubles with subroutine double_it&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt;  &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$\=&amp;quot; &amp;quot;; &lt;span style="color: rgb(153, 102, 51);"&gt;# $\ is the built-in variable to specify the output record separator.&lt;/span&gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(@doubles){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Output:&lt;br&gt; &lt;br&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;2 4 6 8 10 12 14 16 18 20&lt;/span&gt;&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114596052590875196?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114596052590875196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114596052590875196' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114596052590875196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114596052590875196'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-map-with-your-subroutines.html' title='Perl : map() with your subroutines'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114595895137755610</id><published>2006-04-25T02:55:00.000-07:00</published><updated>2006-04-25T02:55:51.453-07:00</updated><title type='text'>Perl : map function</title><content type='html'>See what the following code does.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Code:&lt;/span&gt;&lt;br style="font-weight: bold;"&gt; &lt;br style="font-weight: bold; color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@numarray = (97 .. 122);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@charray = map(chr, @numarray);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print @charray;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Output:&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;abcdefghijklmnopqrstuvwxyz&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Explanation:&lt;/span&gt;&lt;br&gt; &lt;ul&gt;   &lt;li&gt;.. is a range operator. &lt;span style="color: rgb(153, 102, 51);"&gt;@numarray&lt;/span&gt; contains numbers from 97 to 122&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;map&lt;/span&gt; function applies function char on each element of &lt;span style="color: rgb(153, 102, 51);"&gt;@numarray&lt;/span&gt;. The output is stored in &lt;span style="color: rgb(153, 102, 51);"&gt; @charray&lt;/span&gt;.&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;chr&lt;/span&gt; function returns the character represented by that NUMBER in the character set.&amp;nbsp; For example, &amp;quot;chr(65)&amp;quot; is &amp;quot;A&amp;quot;. &lt;br&gt;   &lt;/li&gt;   &lt;li&gt;For more information on built-in perl functions, do '&lt;span style="color: rgb(153, 102, 51);"&gt;man perlfunc&lt;/span&gt;'.&lt;/li&gt; &lt;/ul&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114595895137755610?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114595895137755610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114595895137755610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114595895137755610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114595895137755610'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-map-function.html' title='Perl : map function'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114585690216645992</id><published>2006-04-23T22:35:00.000-07:00</published><updated>2006-04-23T22:35:02.213-07:00</updated><title type='text'>PHP : Showing an image randomly from a collection of images</title><content type='html'>Following code shows one .jpg image randomly from all images in a directory. The code needs to be saved in a file in the directory containing the images. This code can be used for creating random image gallery.&lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;lt;?php&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;############### settings #############&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;$path = &amp;quot;/image_gallery/&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;#######################################&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$dir = $_SERVER['DOCUMENT_ROOT'].$path;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$ig = Array();&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;if (is_dir($dir)) {&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($dh = opendir($dir)) {&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (($file = readdir($dh)) !== false) {&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(ereg(&amp;quot;\.jpg$&amp;quot;,$file))&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array_push($ig,$file);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; closedir($dh);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$num = mt_rand(0,count($ig)-1);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;echo &amp;quot;&amp;lt;img src=\&amp;quot;&amp;quot;.$ig[$num].&amp;quot;\&amp;quot;&amp;gt;&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;?&amp;gt;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes :&lt;/span&gt;&lt;br&gt; &lt;ol&gt;   &lt;li&gt;The code opens a directory specified by $dir and puts all jpg filenames in an array $ig.&lt;br&gt;   &lt;/li&gt;   &lt;li&gt;mt_rand function returns an integer between 0 and count of $ig i.e. number of jpg images in the directory.&lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114585690216645992?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114585690216645992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114585690216645992' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114585690216645992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114585690216645992'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/php-showing-image-randomly-from.html' title='PHP : Showing an image randomly from a collection of images'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114536467661078629</id><published>2006-04-18T05:51:00.000-07:00</published><updated>2006-04-22T20:36:53.476-07:00</updated><title type='text'>CSS : Chaging cursor styles</title><content type='html'>By changing the value of &lt;span style="color: rgb(153, 102, 51);"&gt;cursor&lt;/span&gt;, you can change the appearance of the cursor. Cursor may have one of the following values.&lt;ul&gt;&lt;li style="color: rgb(153, 102, 51);"&gt;auto&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;crosshair&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;default&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;help&lt;br /&gt;&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;move&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;pointer&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;progress&lt;/li&gt;   &lt;li style="color: rgb(153, 102, 51);"&gt;text&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(153, 102, 51);"&gt;wait&lt;/span&gt;&lt;br /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p style="cursor: auto;"&gt;Move mouse over the lines below to see how the cursors look !&lt;/p&gt; &lt;p style="cursor: auto; font-weight: bold;"&gt;Cursor auto&lt;/p&gt; &lt;p&gt;When the value of cursor is set to &lt;span style="color: rgb(153, 102, 51);"&gt;auto&lt;/span&gt;, browser determines what style to show depending upon the context. i.e. if it sees&lt;br /&gt;a link, it shows a &lt;span style="color: rgb(153, 102, 51);"&gt;pointer&lt;/span&gt; (a hand), &lt;span style="color: rgb(153, 102, 51);"&gt;default&lt;/span&gt; otherwise.&lt;/p&gt;&lt;p style="cursor: crosshair; font-weight: bold;"&gt;Cursor crosshair&lt;/p&gt;&lt;p style="cursor: help; font-weight: bold;"&gt;Cursor help&lt;/p&gt;&lt;p style="cursor: default; font-weight: bold;"&gt;Cursor default&lt;/p&gt;&lt;p style="cursor: move; font-weight: bold;"&gt;Cursor move&lt;/p&gt;&lt;p style="cursor: pointer; font-weight: bold;"&gt;Cursor pointer&lt;/p&gt;&lt;p style="cursor: progress; font-weight: bold;"&gt;Cursor progress&lt;/p&gt;&lt;p style="cursor: text; font-weight: bold;"&gt;Cursor text&lt;/p&gt;&lt;p style="cursor: wait; font-weight: bold;"&gt;Cursor wait&lt;/p&gt; &lt;p&gt; Changing cursor styles with CSS adds great functionality to web pages. This can also be done in JavaScript. For Rich Web Applications (that use XMLHttpRequest for speed and better interaction), it's a good idea to change the cursor style to 'wait' after sending request to the server so that user expects some response from the server to be seen somewhere in the web page.&lt;/p&gt; &lt;p&gt; Following line sets cursor style to wait.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;document.body.style.cursor="wait";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After loading completely the response from the server, the style may again be set to &lt;span style="color: rgb(153, 102, 51);"&gt;default&lt;/span&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114536467661078629?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114536467661078629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114536467661078629' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114536467661078629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114536467661078629'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/css-chaging-cursor-styles.html' title='CSS : Chaging cursor styles'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114526651277115014</id><published>2006-04-17T02:35:00.000-07:00</published><updated>2006-04-17T02:43:27.586-07:00</updated><title type='text'>Ajax - The key to Rich Web Applications</title><content type='html'>&lt;b&gt;A&lt;/b&gt;synchronous &lt;b&gt;J&lt;/b&gt;avaScript &lt;b&gt;A&lt;/b&gt;nd &lt;b&gt;X&lt;/b&gt;ML is a web development technique for developing rich web applications. AJAX is aimed at increasing speed, interactivity and usability of web applications. &lt;a href="http://en.wikipedia.org/wiki/AJAX"&gt;More info from Wikipedia&lt;/a&gt;.&lt;br&gt; &lt;br&gt; Typically (in most cases), getting a response from server involves refreshing/reloading the page you are viewing or going to a new page. With ajax, you can do it without refreshing. This is ajax in short :-) The natural question that should arise is 'HOW?'. Modern browsers come with support for an object called &lt;span style="color: rgb(153, 102, 51);"&gt;XMLHttpRequest&lt;/span&gt;. This object is used in ajax applications that require making an http request to the server and loading the response without refreshing the page.&lt;br&gt; &lt;br&gt; While creation of an online account you have to provide a username. And if somebody has already taken it, you come to know about it only after submission of the form. This can now be avoided ! You can send an http request to the server with the username filled in by the new user as soon as the user leaves the text-field (onBlur event of javascript). The response can be shown next to the textfield so that user notices it immediately (as soon as it appears there).&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;So why should you use ajax ?&lt;br&gt; &lt;br&gt; &lt;/span&gt;1. With ajax, you don't have to refresh your page for server responses.&lt;br&gt; 2. You can get only the required server reponse and show in the desired place on your web-page. This reduces the byte-transfer considerably. There's no need to transfer all the html that show your headers, footers, images and navigation.&lt;br&gt; &lt;br&gt; The methods and properties of this object are explained below.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;var request = new XMLHttpRequest();&lt;/span&gt; // creates an object of XMLHttpRequest&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;open()&lt;/span&gt; - new request to server.&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;send() &lt;/span&gt;- Sends a request to the server.&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;abort()&lt;/span&gt; - aborts current request&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;readyState &lt;/span&gt;- provides the current HTML ready state.&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;responseText&lt;/span&gt; - the text that the server sends back to respond to a request.&lt;br&gt; &lt;br&gt; More information on the subject can be found on this &lt;a href="http://www-128.ibm.com/developerworks/web/library/wa-ajaxintro2/?ca=dgr-lnxw07AJAX-Request"&gt;link&lt;/a&gt;.&lt;br&gt; &lt;br&gt; Some examples -&lt;br&gt; 1. &lt;a href="http://www.gmail.com"&gt;www.gmail.com&lt;/a&gt; - most of us know what it is :-)&lt;br&gt; 2. &lt;a href="http://gollum.easycp.de/en/"&gt;http://gollum.easycp.de/en/&lt;/a&gt; - a wikipedia browser&lt;br&gt; 3. &lt;a href="http://a-i-studio.com/cmd/"&gt;http://a-i-studio.com/cmd/&lt;/a&gt; - a WebShell !&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114526651277115014?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114526651277115014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114526651277115014' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114526651277115014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114526651277115014'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/ajax-key-to-rich-web-applications.html' title='Ajax - The key to Rich Web Applications'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114524973989068540</id><published>2006-04-16T21:55:00.000-07:00</published><updated>2006-04-23T06:37:21.710-07:00</updated><title type='text'>Bash : sample loops (shell scripting)</title><content type='html'>Here are some sample loops in bash scripting. Feel free to leave a comment if something is not clear to you. I recommend using bash for learing shell scripting.&lt;br /&gt;--------------------&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;for i in `seq 1 10`&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;do&lt;br /&gt;let i=i*5&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;echo $i&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;--------------------&lt;br /&gt;# &lt;span style="color: rgb(153, 102, 51);"&gt;seq&lt;/span&gt; outputs a sequence of numbers (1 to 10)&lt;br /&gt;# &lt;span style="color: rgb(153, 102, 51);"&gt;let&lt;/span&gt; is a bash built-in command that allows arithmetic operations to be performed and assigned to a variable as done above&lt;br /&gt;---------------&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;for i in $(ls)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;do&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;echo $i&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---------------&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;j=0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;while [ $j -lt 10 ]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;do&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;echo $j&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;let j=j+1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;----------------&lt;br /&gt;# same example with until&lt;br /&gt;# note the &lt;span style="color: rgb(153, 102, 51);"&gt;-eq&lt;/span&gt; switch in &lt;span style="color: rgb(153, 102, 51);"&gt;until&lt;/span&gt; loop&lt;br /&gt;--------------------&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;j=0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;until [ $j -eq 10 ]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;do&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;echo $j&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;let j=j+1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---------------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114524973989068540?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114524973989068540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114524973989068540' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114524973989068540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114524973989068540'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/bash-sample-loops-shell-scripting_16.html' title='Bash : sample loops (shell scripting)'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114490738341936755</id><published>2006-04-12T22:49:00.000-07:00</published><updated>2006-04-12T22:49:43.470-07:00</updated><title type='text'>Shell scripting</title><content type='html'>&lt;span style="font-weight: bold;"&gt;What is shell scripting ?&lt;br&gt; &lt;br&gt; &lt;/span&gt;A shell script is a file containing unix/linux commands. Shell scripts are written to avoid repetitive work of issuing the same set of commands over and again. Shell grammar allows us to put conditional and looping constructs (as commands) making it easy to write scripts to do complex tasks.&lt;br clear="all"&gt; &lt;br&gt; Following is a simple shell script that shows date, operating system info and list of files in a working directory.&lt;br&gt; &lt;br&gt; ----------------------------&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;## simple.sh (filename)&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;echo &amp;quot;a simple shell script&amp;quot;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;date&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;uname -a&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ls&lt;/span&gt;&lt;br&gt; ----------------------------&lt;br&gt; Lines starting with a &lt;span style="color: rgb(153, 102, 51);"&gt;#&lt;/span&gt; are comments.&lt;br&gt; &lt;br&gt; To execute this script,&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;bash simple.sh&lt;/span&gt;&lt;br&gt; or&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;sh simple.sh&lt;/span&gt;&lt;br&gt; &lt;br&gt; Shell scripts can be used like any other operating system commands. For this they need to be placed in a directory which the shell searches for commands. You can see these directories by&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;echo $PATH&lt;/span&gt;&lt;br&gt; &lt;br&gt; You can update the envronment variable PATH to add your own directory to it. Say you want to add ~/bin (directory bin in your home), issue the following commands (bash specific).&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;PATH=$PATH:$HOME/bin&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;export PATH&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; The scripts/programs in this directory need to have execute permission if you want to use them as commands. Execute permission can be added by using chmod command&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chmod +x scriptfile&lt;/span&gt;&lt;br&gt; &lt;br&gt; I'll post some examples of small shell scripts in next few posts.&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114490738341936755?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114490738341936755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114490738341936755' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114490738341936755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114490738341936755'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/shell-scripting.html' title='Shell scripting'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114473744901634001</id><published>2006-04-10T23:37:00.000-07:00</published><updated>2006-04-10T23:37:29.056-07:00</updated><title type='text'>Linux/Unix : File permissions, groups and access control</title><content type='html'>There are three types of permissions namely &lt;span style="color: rgb(153, 102, 51);"&gt;r&lt;/span&gt;(read), &lt;span style="color: rgb(153, 102, 51);"&gt;w&lt;/span&gt;(write), &lt;span style="color: rgb(153, 102, 51);"&gt;x&lt;/span&gt;(execute).&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;Read permission&lt;/span&gt; - in context of a file, this means you can read (and thus copy) the file. If you have read permission on a directory, you can see the contents of the directory (usually with ls command).&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;Write permission&lt;/span&gt; - on file means you can change the contents of the file. Write permission on a directory means you can create or delete files/directories in that directory.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;Execute permission&lt;/span&gt; - If a file has execute permission you can run it just like a command. Usually, shell scripts, if they are used like a command, need x permission for the user. Execute permission on a directory means you can change to that directory using cd command.&lt;br&gt; &lt;br&gt; On Linux (and unix flavors) users can be put in groups. A given set of users works on the files owned by a certain group. One user can be a member of many groups. Access control becomes effective with proper use of groups and permissions.&lt;br&gt; &lt;br&gt; Long listing format (ls -l) shows the permissions on a file/directory.&lt;br&gt; &lt;br&gt; The output is of the following form&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;-rw-rw-r--&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 abcd&amp;nbsp; web&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24593 Mar&amp;nbsp; 4&amp;nbsp; 2006 test.txt&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;drwxrwxr-x&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 abcd&amp;nbsp; web&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4096 Oct&amp;nbsp; 7 16:06 temp_files&lt;/span&gt;&lt;br&gt; &lt;br&gt; The first field shows the permissions on the files. Second field shows number of files in the corresponding directory. Third&lt;br&gt; &amp;nbsp;field (abcd) is the owner of the file. Next is the name of the group. Other fields are file-size, modification time and fil&lt;br&gt; ename in the same order.&lt;br&gt; &lt;br&gt; The permissions field consists of 10 characters. First denotes the file-type. '-' for a plain file, 'd' for a directory. Following three characters show permissions of the owner of the file. In our case, the owner is 'abcd' and his permissions are 'rw-' (read, write but no execute). Following three characters are for the group (web). In our case, all members of this group have rw- permissions i.e. the same as the owner. Next three charaters are for others. Others have just 'read' permission.&lt;br&gt; &lt;br style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Types of files&lt;/span&gt;&lt;br style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;----------------&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;d - directory&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;l - link&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;p - pipe&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;b - block special device&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;c - character special device&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Changing permissions&lt;/span&gt;&lt;br&gt; --------------------------&lt;br&gt; Only owner or root (administrator) can change permissions on a file. Following are some illustrations.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chgrp web filename&lt;/span&gt;&lt;br&gt; changes group of the file to web.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chmod g+w somefile&lt;/span&gt;&lt;br&gt; gives write permission on somefile to group.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chmod +x some_script&lt;/span&gt;&lt;br&gt; gives execute permission to all on some_script. Typically, shell scripts or some other executable files are given execute permissions.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chmod o-x some_script&lt;/span&gt;&lt;br&gt; removes execute permission for others (but retains for the owner and the group)&lt;br&gt; &lt;br&gt; If in chmod command permissions start with a letter, following are the meanings of these letters&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;u - user or owner of the file&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;g - group members&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;o - others (rest of the world)&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;a - all&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;br&gt; What does the following command mean then ?&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;chmod 664 some_filename&lt;/span&gt;&lt;br&gt; &lt;br&gt; Permissions can also be set using octal value for the three bit pattern. Using this method, permissions on a file can be set in one go. r, w and x have corresponding values.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;r = 4&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;w = 2&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;x = 1&lt;/span&gt;&lt;br&gt; &lt;br&gt; Therefore, the above command assigns 6=4+2 i.e. 'read' and 'write' to the owner of the file, same for group whereas others have just 4 i.e. 'read' permissions on the file. To get more information on changing permissions refer the man page of chmod.&lt;br&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114473744901634001?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114473744901634001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114473744901634001' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114473744901634001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114473744901634001'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/linuxunix-file-permissions-groups-and.html' title='Linux/Unix : File permissions, groups and access control'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114473190285240034</id><published>2006-04-10T22:05:00.000-07:00</published><updated>2006-04-10T22:05:02.856-07:00</updated><title type='text'>Perl : Arrays [2]</title><content type='html'>In this chapter, I'll discuss some frequently performed functions on Perl arrays.&lt;br&gt; &lt;br&gt; Let's consider this array&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;@fruit = (&amp;quot;apple&amp;quot;,&amp;quot;banana&amp;quot;,&amp;quot;pineapple&amp;quot;,&amp;quot;mango&amp;quot;,&amp;quot;guava&amp;quot;);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;push @fruit,&amp;quot;plum&amp;quot;;&lt;/span&gt;&lt;br&gt; Adds an element to the end of the array.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my $new_fruit = shift&amp;nbsp; @fruit;&lt;/span&gt;&lt;br&gt; The above statement removes the first element of @fruits and assigns it to $new_fruit.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my $popped_fruit = pop @fruit;&lt;/span&gt;&lt;br&gt; The above line pops (removes last element from the list) and assigns it to $popped_fruit.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Use of &lt;/span&gt;&lt;span style="color: rgb(51, 0, 51); font-weight: bold;"&gt;@_&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; in a subroutine&lt;/span&gt;&lt;br style="font-weight: bold;"&gt; &lt;br&gt; @_ is the default array that is passed to a subroutine.&lt;br&gt; See the following two subroutines and what they do&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;sub test{&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;($name,$surname,$age)=@_;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br&gt; &lt;br&gt; We can assign three scalars of a subroutine with the values of the arguments to the subroutines. @_ is the array of argument&lt;br&gt; s passed to the subroutine.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;sub test2{&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$name = shift;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$surname=shift;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$age=shift;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; If these arguments are not going to be required for further processing, the default array can be shift'ed and the assignment&lt;br&gt; &amp;nbsp;be made.&lt;br&gt; &lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114473190285240034?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114473190285240034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114473190285240034' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114473190285240034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114473190285240034'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-arrays-2_10.html' title='Perl : Arrays [2]'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114465461739162660</id><published>2006-04-10T00:36:00.000-07:00</published><updated>2006-04-10T00:36:57.893-07:00</updated><title type='text'>Linux : Use of Pipes in commands</title><content type='html'>A pipe ( | ) is used to send output of one command to some other command. Many a time, use of pipe simplifies our task to a great extent. I'll discuss a few examples &lt;br&gt; &lt;br&gt; Count number of files in a directory&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ls | wc -l&lt;/span&gt;&lt;br&gt; &lt;br&gt; List all users on a system who are running some processes (process owners)&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ps -ef | cut -d &amp;quot; &amp;quot; -f1 | sort | uniq&lt;/span&gt;&lt;br&gt; &lt;br&gt; List all process-listings that contain the word &amp;quot;mozilla&amp;quot;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ps -ef | grep mozilla&lt;/span&gt;&lt;br&gt; &lt;br&gt; Find the word &amp;quot;services&amp;quot; in all .htm files&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;find . -name &amp;quot;*.htm&amp;quot; | xargs grep &amp;quot;services&amp;quot;&lt;/span&gt;&lt;br&gt; &lt;br&gt; Sort lines in a file and print on the console&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;cat filename | sort&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; Killing mozilla &lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;ps -ef | grep &amp;quot;mozilla&amp;quot; | cut -f1 | xargs kill&lt;/span&gt;&lt;em&gt;&lt;br&gt; &lt;/em&gt;&lt;br&gt; Print last 10 lines of a file &lt;br&gt; &lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;tail filename | lpr&lt;/span&gt;&lt;br&gt; &lt;br&gt; Here's a good page on &lt;a href="http://www.gnuservices.com/linux_tips/"&gt;Linux Tips&lt;/a&gt;.&lt;br clear="all"&gt;&lt;br&gt; &lt;a href="http://en.wikipedia.org/wiki/Pipe_%28Unix%29"&gt;This wikipedia page&lt;/a&gt; has more information on unix pipes.&lt;br&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114465461739162660?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114465461739162660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114465461739162660' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114465461739162660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114465461739162660'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/linux-use-of-pipes-in-commands.html' title='Linux : Use of Pipes in commands'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114441225869364911</id><published>2006-04-07T05:17:00.000-07:00</published><updated>2006-04-07T20:51:09.923-07:00</updated><title type='text'>Perl : Arrays in perl</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Creation of arrays&lt;/span&gt;&lt;br&gt; &lt;br&gt; Following statements create perl arrays.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my @fruits = (&amp;quot;apples&amp;quot;,&amp;quot;bananas&amp;quot;,&amp;quot;mangoes&amp;quot;,&amp;quot;grapes&amp;quot;);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my @numbers = (23, 42, 69);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my @mixed&amp;nbsp;&amp;nbsp; = (&amp;quot;bananas&amp;quot;, 4.2, 25);&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; Creating arrays from other arrays.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my @new_fruits = @fruits[1..3]&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; This cerates a new array which has &amp;quot;bananas&amp;quot;,&amp;quot;mangoes&amp;quot; and &amp;quot;grapes&amp;quot; of @fruits. This is called an array slice.&lt;br&gt; Some more ways ...&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my @new_fruits = @fruits[1..$#fruits]&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;$#&lt;/span&gt; is a special variable which gives the last index of an array.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;my @new_fruits = @fruits[1,2]&lt;/span&gt;&lt;br&gt; creates array of 2nd and 3rd element of @fruits.&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Looping through arrays&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$\=&amp;quot;\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;for (1..12){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br clear="all"&gt;Probably the simplest form to understand. You can set a range with '&lt;span style="color: rgb(153, 102, 51);"&gt;..&lt;/span&gt;'&lt;br&gt; No argument is provided to 'print' so it takes the default input to the loop.&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;$\&lt;/span&gt; is the output field separator. In our case, it's a newline. Alternatively, (without the first line) we could have written the print statement as follows.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print &amp;quot;$_\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;$_&lt;/span&gt; is the default input. As in the first case, perl assumes the default input '$_' as an argument to print (and other) statements if not mentioned explicitly.&lt;br&gt; &lt;br&gt; The following code prints the locations of the perl modules on your system. @INC is the predefined perl array.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;for (@INC){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print &amp;quot;$_\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; If used in scalar context, @fruits gives the number of elements in @fruits (array).&lt;br&gt; e.g. &lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;$x = @fruits;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;print $x; &lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; This prints 4 (number of elements in the array).&lt;br&gt; &lt;br&gt; Some more on perl arrays will be posted here soon. Stay tuned !&lt;br&gt; &lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114441225869364911?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114441225869364911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114441225869364911' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114441225869364911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114441225869364911'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-arrays-in-perl.html' title='Perl : Arrays in perl'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114406486764431868</id><published>2006-04-03T04:47:00.000-07:00</published><updated>2006-04-03T04:47:48.780-07:00</updated><title type='text'>Perl : Sorting a hash</title><content type='html'>Consider this hash.&lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;%my_hash = (&amp;quot;apple&amp;quot;=&amp;gt;20,&amp;quot;banana&amp;quot;=&amp;gt;5,&amp;quot;chiku&amp;quot;=&amp;gt;10,&amp;quot;pineapple&amp;quot;=&amp;gt;30,&amp;quot;mango&amp;quot;=&amp;gt;50);&lt;/span&gt;&lt;br&gt; &lt;br&gt; Keys of this hash are names of fruit and the values are numbers.&lt;br&gt; With 'sort' and 'keys' functions we get a hash sorted by its keys.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;foreach $k(sort keys %my_hash){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;quot;$k =&amp;gt; $my_hash{$k}\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; This prints&lt;br&gt; ----------------------&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;apple =&amp;gt; 20&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;banana =&amp;gt; 5&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;chiku =&amp;gt; 10&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;mango =&amp;gt; 50&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;pineapple =&amp;gt; 30&lt;/span&gt;&lt;br&gt; ----------------------&lt;br&gt; &lt;br&gt; Following code reverse-sorts the same hash by its values and prints it.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;foreach $k(sort { $my_hash{$b} &amp;lt;=&amp;gt; $my_hash{$a} } keys %my_hash){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;quot;$k =&amp;gt; $my_hash{$k}\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;br&gt; Output&lt;br&gt; ---------------------&lt;br&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;mango =&amp;gt; 50&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;pineapple =&amp;gt; 30&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;apple =&amp;gt; 20&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;chiku =&amp;gt; 10&lt;/span&gt;&lt;br style="color: rgb(153, 102, 51);"&gt; &lt;span style="color: rgb(153, 102, 51);"&gt;banana =&amp;gt; 5&lt;/span&gt;&lt;br&gt; ---------------------&lt;br&gt; &lt;br clear="all"&gt;The above can be done with this code.&lt;br&gt; &lt;br&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;foreach $k(reverse sort { $my_hash{$a} &amp;lt;=&amp;gt; $my_hash{$b} } keys %my_hash){&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;quot;$k =&amp;gt; $my_hash{$k}\n&amp;quot;;&lt;/span&gt;&lt;br style="color: rgb(0, 102, 0);"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;Notes :&lt;/span&gt;&lt;br&gt; &lt;ul&gt;   &lt;li&gt;'reverse' has been added in the above code so that sorting takes place in revese way. However, the positions of $a and $b have changed too.&lt;/li&gt;   &lt;li&gt;&amp;lt;=&amp;gt; is used for numerical comparison. This is the comparison operator.&lt;/li&gt;   &lt;li&gt;'cmp' is used for comparison of strings.&lt;/li&gt;   &lt;li&gt;The operators '&amp;lt;=&amp;gt;' and 'cmp' return either of 1,0,-1. These when used with 'sort' do the sorting !&lt;br&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114406486764431868?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114406486764431868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114406486764431868' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114406486764431868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114406486764431868'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/perl-sorting-hash.html' title='Perl : Sorting a hash'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114404292978642690</id><published>2006-04-02T22:42:00.000-07:00</published><updated>2006-04-02T22:42:09.826-07:00</updated><title type='text'>Knowledge management with Perlfect (a search engine coded in Perl)</title><content type='html'>We tend to forget things that we knew once and time has to be spent either in digging the old archives/notes or learning the same thing afresh. Yes, many people have to deal with such a range of subjects that they can not recall everything when they need it. For example, a LAMP freelancer will find it hard to remember all Apache (web-server) directives and the new directives that came with the latest version. Besides, this programmer needs to have quick access to Linux, MySQL, PHP, Perl related documents. Efficient knowledge management will certainly boost his/her performance. This becomes more beneficial if knowledge can be shared in a group or organization.&lt;br&gt;&lt;br&gt;This is typically done by running an intranet website on the Local Area Network and running a search engine to index the documents on it.&lt;br&gt;&lt;font size="4"&gt;&lt;br&gt; &lt;span style="font-weight: bold; color: rgb(153, 102, 51);"&gt;How can I set up an intranet website ?&lt;/span&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;You need to run a web-server. Apache which is a free software is the web-server of our choice. If you have a LAN, you should be able to access your intranet from any computer on the Local Area Network.&lt;br&gt;&lt;br&gt;&lt;font size="4"&gt;&lt;span style="color: rgb(153, 102, 51); font-weight: bold;"&gt;Knowledge management with Perlfect&lt;/span&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;Perfect is a search engine developed in Perl and distributed under GNU GPL (General Public License). You can download and use this for free. Once installed, you need to run the indexer to index the files on your intranet. You are all set to use the results !&lt;br&gt;&lt;br&gt;Create a directory on your intranet to save your knowledge-documents and get the files indexed. A LAMP programmer may want to download php documentation, to be indexed so that he does not have to search the internet often. Text and pdf documents are also indexed so you can save your own tips/tricks in text files for future reference.&lt;br&gt;&lt;br&gt;&lt;font size="4"&gt;&lt;span style="font-weight: bold; color: rgb(153, 102, 51);"&gt;Contributing to the growth of your Knowledge base&lt;/span&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;If you are working in a group, encourage everybody to save their tips, findings in text files or any other format that Perlfect understands. While writing your knowledge-document, make sure you include all the possible search phrases that a user is likely to use. Assign the responsibility to run the indexer once in a week or more frequently depending upon the size of your group. Perlfect search form can be set to search within a particular directory so you can have different forms for different subdirectories of your intranet if the search starts yielding too many results. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114404292978642690?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114404292978642690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114404292978642690' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114404292978642690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114404292978642690'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/04/knowledge-management-with-perlfect.html' title='Knowledge management with Perlfect (a search engine coded in Perl)'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114386581329046578</id><published>2006-03-31T20:30:00.000-08:00</published><updated>2006-03-31T20:33:40.190-08:00</updated><title type='text'>Linux/Unix: vi/vim editing tips</title><content type='html'>&lt;span class="gmail_quote"&gt;&lt;/span&gt;&lt;span class="gmail_quote"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;How do I see line numbers ?&lt;/span&gt;&lt;br /&gt;&lt;div style="direction: ltr;"&gt;&lt;span class="e" id="q_10a53b3eba6f0b66_0"&gt;&lt;div style="direction: ltr;"&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;:set nu&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;       :set nonu&lt;/span&gt;&lt;br /&gt;     does the opposite.&lt;br /&gt;&lt;br /&gt;Indentation for formatting your programs/scripts&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;:set autoindent&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Saving vi/vim preferences &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can create a file (a hidden file) by name .exrc and write all your ex commands one per line. You can copy-paste the following two lines as &lt;span style="color: rgb(0, 102, 0);"&gt;.exrc&lt;/span&gt;. These options/preferences will work next time you open vi.&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;   set autoindent&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;     set nu&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Moving around quickly&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   * Last line - &lt;span style="color: rgb(0, 102, 0);"&gt;   shift+g&lt;/span&gt;&lt;br /&gt;   * First line - &lt;span style="color: rgb(0, 102, 0);"&gt;gg&lt;/span&gt;&lt;br /&gt;   * One screen forward - &lt;span style="color: rgb(0, 102, 0);"&gt;ctrl+f&lt;/span&gt;&lt;br /&gt;   * One screen backward - &lt;span style="color: rgb(0, 102, 0);"&gt;   ctrl+b&lt;/span&gt;&lt;br /&gt;   * Half screen forward (down) - &lt;span style="color: rgb(0, 102, 0);"&gt;ctrl+d&lt;/span&gt;&lt;br /&gt;   * Half screen backward (up) - &lt;span style="color: rgb(0, 102, 0);"&gt;ctrl+u&lt;/span&gt;&lt;br /&gt;   * 50th line - &lt;span style="color: rgb(0, 102, 0);"&gt;   50,shift+g&lt;/span&gt;&lt;br /&gt;   * Move forward a word - &lt;span style="color: rgb(0, 102, 0);"&gt;w&lt;/span&gt;&lt;br /&gt;   * Move back a word - &lt;span style="color: rgb(0, 102, 0);"&gt;b&lt;/span&gt;&lt;br /&gt;   * To start of line - &lt;span style="color: rgb(0, 102, 0);"&gt;   0&lt;/span&gt;&lt;br /&gt;   * To end of line - &lt;span style="color: rgb(0, 102, 0);"&gt;$&lt;/span&gt;&lt;br /&gt;   * Down a line - &lt;span style="color: rgb(0, 102, 0);"&gt;j&lt;/span&gt;&lt;br /&gt;   * Up a line - &lt;span style="color: rgb(0, 102, 0);"&gt;k&lt;/span&gt;&lt;br /&gt;    * One char left -  &lt;span style="color: rgb(0, 102, 0);"&gt;h&lt;/span&gt;&lt;br /&gt;   * One char right - &lt;span style="color: rgb(0, 102, 0);"&gt;l&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Deleting content&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   * Delete a character - &lt;span style="color: rgb(0, 102, 0);"&gt;   x&lt;/span&gt;&lt;br /&gt;   * Delete a word - &lt;span style="color: rgb(0, 102, 0);"&gt;dw&lt;/span&gt;&lt;br /&gt;   * Delete a line - &lt;span style="color: rgb(0, 102, 0);"&gt;dd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can multiply these commands with numbers ! e.g. '&lt;span style="color: rgb(0, 102, 0);"&gt;   5dw&lt;/span&gt;' deletes 5 words.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Chaging content&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   * Change word - &lt;span style="color: rgb(0, 102, 0);"&gt;cw&lt;/span&gt;&lt;br /&gt;   * Change line - &lt;span style="color: rgb(0, 102, 0);"&gt;cc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;   Inserting content&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;You can go into insert mode by following ways&lt;br /&gt;&lt;br /&gt;   * Insert where cursor is - &lt;span style="color: rgb(0, 102, 0);"&gt;i&lt;/span&gt;&lt;br /&gt;   * From start of line - &lt;span style="color: rgb(0, 102, 0);"&gt;I (shift+i)&lt;/span&gt; &lt;br /&gt;   * Next line - &lt;span style="color: rgb(0, 102, 0);"&gt;o&lt;/span&gt;&lt;br /&gt;   * Previous line - &lt;span style="color: rgb(0, 102, 0);"&gt;O (shift+o)&lt;/span&gt;&lt;br /&gt;   * Next character - &lt;span style="color: rgb(0, 102, 0);"&gt;a&lt;/span&gt;&lt;br /&gt;   * End of line - &lt;span style="color: rgb(0, 102, 0);"&gt;A (shift+a)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Copying and pasting&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The command to copy content is 'y' (yank).&lt;br /&gt;&lt;br /&gt;   * Copy a line - &lt;span style="color: rgb(0, 102, 0);"&gt;yy&lt;/span&gt;&lt;br /&gt;   * Copy a word - &lt;span style="color: rgb(0, 102, 0);"&gt;yw&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Copy 5 lines - &lt;span style="color: rgb(0, 102, 0);"&gt;   5yy&lt;/span&gt; as explained above. Multiplication applies here as well.&lt;br /&gt;Paste - &lt;span style="color: rgb(0, 102, 0);"&gt;p&lt;/span&gt;&lt;br /&gt;Paste before the cursor position/previous line - &lt;span style="color: rgb(0, 102, 0);"&gt;P (shift+p) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Content from the last delete (cut) command is stored in a buffer by default. dd followed by p cuts current line and pastes it after the next line. Similarly, x followed by p swaps the chars of a word.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Saving and reading files&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   * &lt;span style="color: rgb(0, 102, 0);"&gt;:r filename&lt;/span&gt; - read file named filename and insert after current line (the line with cursor)&lt;br /&gt;   *  &lt;span style="color: rgb(0, 102, 0);"&gt;:w&lt;/span&gt; - write current contents to file named in original vi call&lt;br /&gt;   * &lt;span style="color: rgb(0, 102, 0);"&gt;:w newfile&lt;/span&gt; - write current contents to a new file named newfile&lt;br /&gt;   * &lt;span style="color: rgb(0, 102, 0);"&gt;:12,35w smallfile&lt;/span&gt; - write the contents of the lines numbered 12 through 35 to a new file named smallfile&lt;br /&gt;   * &lt;span style="color: rgb(0, 102, 0);"&gt;:w! prevfile&lt;/span&gt;    - write current contents over a pre-existing file named prevfile&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Find and replace (substitutions)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    This is normally done with ex editor command. Following is the syntax.&lt;br /&gt;    For replacing everywhere in the file,&lt;br /&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;:1,$s/pattern/replacement/g&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Explanation&lt;br /&gt;&lt;br /&gt;    : indicates the start of an ex editor command&lt;br /&gt;    1,$ - from the first line to the last line. Alternatively, you can use % (for all lines of a file)&lt;br /&gt;    / used to separate pattern and replacement. Here, you can use regular expressions.&lt;br /&gt;    g stands for all occurences of the pattern on a line&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114386581329046578?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114386581329046578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114386581329046578' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114386581329046578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114386581329046578'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/03/linuxunix-vivim-editing-tips.html' title='Linux/Unix: vi/vim editing tips'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114386387117246396</id><published>2006-03-31T19:40:00.000-08:00</published><updated>2006-03-31T19:57:51.180-08:00</updated><title type='text'>Linux/Unix: Environment variables</title><content type='html'>&lt;span style="font-weight: bold;"&gt;What are they ?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Environment variables are a set of dynamic &lt;a href="http://en.wikipedia.org/wiki/Value" title="Value"&gt;&lt;/a&gt;values that can affect the way running processes will behave. All unix like operating systems as well as windows have their set of enviraonment variables. In unix like systems change in environment variable will affect only the child process run by that particular program or shell script which changes the environment.&lt;br /&gt;&lt;br /&gt;Examples -&lt;br /&gt;&lt;br /&gt;$PATH - shows the directories where shell looks for commands issued by a user&lt;br /&gt;$HOME - shows where user's home directory is located on the file-system&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 102, 0);"&gt;env&lt;/span&gt; command shows all environment variables specific to your login.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Setting an environment variable&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;In bash,  following two commands set up an environment variable called 'name'&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&gt; name=Ketan&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&gt; export name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To verify this, you can&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&gt; echo $name&lt;/span&gt;&lt;br /&gt;or&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&gt; env | grep name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you want a certain environment variable to be set when you login, keep the two commands in your .bashrc file.&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114386387117246396?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114386387117246396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114386387117246396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114386387117246396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114386387117246396'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/03/linuxunix-environment-variables.html' title='Linux/Unix: Environment variables'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-25125788.post-114380779411094607</id><published>2006-03-31T04:20:00.000-08:00</published><updated>2006-04-10T21:43:47.430-07:00</updated><title type='text'>Misc: why the name "Ketan's weekly"?</title><content type='html'>I intend to post something here on weekends. Rarely on weekdays :-)&lt;br /&gt;Hope you find this blog useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/25125788-114380779411094607?l=ketan404.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ketan404.blogspot.com/feeds/114380779411094607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=25125788&amp;postID=114380779411094607' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114380779411094607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/25125788/posts/default/114380779411094607'/><link rel='alternate' type='text/html' href='http://ketan404.blogspot.com/2006/03/misc-why-name-ketans-weekly.html' title='Misc: why the name &quot;Ketan&apos;s weekly&quot;?'/><author><name>Ketan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
