<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>TechDiary</title><link>http://techdiary-viki.blogspot.com/</link><description>My experience in using various languages, commands, OS, etc</description><language>en</language><managingEditor>noreply@blogger.com (Viki)</managingEditor><lastBuildDate>Wed, 04 Nov 2009 05:37:36 PST</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">31</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">25</openSearch:itemsPerPage><media:keywords>perl,scripting,shell,script</media:keywords><media:category scheme="http://www.itunes.com/dtds/podcast-1.0.dtd">Education/Educational Technology</media:category><media:category scheme="http://www.itunes.com/dtds/podcast-1.0.dtd">Technology</media:category><itunes:owner><itunes:email>vikas.nv@gmail.com</itunes:email><itunes:name>Viki</itunes:name></itunes:owner><itunes:author>Viki</itunes:author><itunes:explicit>no</itunes:explicit><itunes:keywords>perl,scripting,shell,script</itunes:keywords><itunes:subtitle>Perl: Tips &amp; Tutorials</itunes:subtitle><itunes:category text="Education"><itunes:category text="Educational Technology" /></itunes:category><itunes:category text="Technology" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Techdiary" type="application/rss+xml" /><feedburner:emailServiceId>Techdiary</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>Extract or Reap or Download Pictures from HTML Web Pages</title><link>http://feedproxy.google.com/~r/Techdiary/~3/Ak-B_aBVvRM/extract-or-reap-images-from-html-web.html</link><category>jpeg reaper</category><category>extract jpeg files</category><category>extract pictures webpage</category><category>download pictures</category><category>web reaper</category><category>picture reaper</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Thu, 13 Aug 2009 04:08:13 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-6279973689533908368</guid><description>&lt;span style="font-family:verdana;"&gt;I was exploring python and the HTML parsers that it has. I hit a page that explained about the SGMLParser and its uses.&lt;br /&gt;&lt;br /&gt;Using this package I had written a simple script that could extract pictures from simple HTML pages. While experimenting it with many websites I noticed some websites did not allow my script to reap or extract pictures.&lt;br /&gt;&lt;br /&gt;Then I found that it is because of the User-Agent string in the HTTP request. Some websites do not respond properly to HTTP requests that have unknown User-Agent string. I then used the urllib's FancyURLOpener to change the User-Agent to Firefox.&lt;br /&gt;&lt;br /&gt;Now that the script work on most of the websites, i would like to post the code here. Feel free to modify to make it more robust and reliable, post a comment or a link to your modified script.&lt;br /&gt;&lt;br /&gt;This script search pictures from web pages and download them for you. All you need to do is&lt;br /&gt;get the URL of the web page from which you want the pictures to be downloaded and pass it as&lt;br /&gt;an argument to this script. Here is how to use it:&lt;br /&gt;    0. Note that python is installed on your system to run this script (Windows/Linux/Solaris ... OS independent;)&lt;br /&gt;    1. Download this script and save it as gal_ext.py&lt;br /&gt;    2. Open a command-prompt (if Windows) or Terminal (if you use any *nix OS)&lt;br /&gt;    3. Type "python gal_ext.py 'http://URL'&lt;br /&gt;    4. Here note that the 'http://' is mandatory&lt;br /&gt;Using this script you can avoid downloading images with a web browser, which takes a long time and is annoying to right click on every image and save them. This way you can download picture from web faster and easier. Since this is a script it is open for modifications and is free to use. But if you modify, make a note to send it to me ;). Thanks&lt;br /&gt;&lt;br /&gt;The code is here (&lt;a href="http://docs.google.com/View?id=dg2jxmfs_51dsk6x7gv"&gt;or a link for you to download&lt;/a&gt;):&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="Python"&gt;&lt;br /&gt;from sgmllib import SGMLParser&lt;br /&gt;import sys&lt;br /&gt;import os&lt;br /&gt;import re&lt;br /&gt;import urllib&lt;br /&gt;from urllib import FancyURLopener&lt;br /&gt;from urlparse import urlparse&lt;br /&gt;&lt;br /&gt;class URLLister(SGMLParser):&lt;br /&gt;def reset(self):&lt;br /&gt;SGMLParser.reset(self)&lt;br /&gt;self.urls = []&lt;br /&gt;&lt;br /&gt;def start_a(self, attrs):&lt;br /&gt;href = [v for k, v in attrs if k=='href']&lt;br /&gt;if href:&lt;br /&gt;self.urls.extend(href)&lt;br /&gt;&lt;br /&gt;class MyURLOpener(FancyURLopener):&lt;br /&gt;version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6'&lt;br /&gt;&lt;br /&gt;def url_mapper(var):&lt;br /&gt;regexp = re.compile('.+?(http://.+&amp;amp;?)', re.I)&lt;br /&gt;values = urlparse(var)&lt;br /&gt;if len(values) &gt;= 5 and values[4] != '':&lt;br /&gt;obj = regexp.search(values[4])&lt;br /&gt;if obj:&lt;br /&gt;values = urlparse(obj.group(1))&lt;br /&gt;else:&lt;br /&gt;if values[4] != '': print('Could not get real url from:' + values[4])&lt;br /&gt;site = re.sub('[^0-9a-zA-Z_/]', '_', values[1])&lt;br /&gt;location_file = re.findall('(.+)/(.+)', values[2])&lt;br /&gt;try:&lt;br /&gt;if len(location_file[0]) != 2:&lt;br /&gt;return ''&lt;br /&gt;except IndexError:&lt;br /&gt;return ''&lt;br /&gt;location = location_file[0][0]&lt;br /&gt;file = location_file[0][1]&lt;br /&gt;location = re.sub('\.{2,}/', '/', location)&lt;br /&gt;location = re.sub('[^0-9a-zA-Z_/]', '_', location)&lt;br /&gt;location = location + '/' + file&lt;br /&gt;return site + location&lt;br /&gt;&lt;br /&gt;if __name__ == '__main__':&lt;br /&gt;url_opener = MyURLOpener()&lt;br /&gt;parser = URLLister()&lt;br /&gt;sys.argv[1] = urllib.unquote(sys.argv[1])&lt;br /&gt;try:&lt;br /&gt;usock = url_opener.open(sys.argv[1])&lt;br /&gt;except IOError:&lt;br /&gt;print 'skipping ' + sys.argv[1]&lt;br /&gt;sys.exit(0)&lt;br /&gt;parser.feed(usock.read())&lt;br /&gt;parser.close()&lt;br /&gt;usock.close()&lt;br /&gt;count = 0&lt;br /&gt;urlfs = urlparse(sys.argv[1])&lt;br /&gt;print "Url fs: ", urlfs&lt;br /&gt;parent = urlfs[1]&lt;br /&gt;try:&lt;br /&gt;parent += urlfs[2]&lt;br /&gt;parent = re.search('(.+)/.+',parent).group(1)&lt;br /&gt;except IndexError:&lt;br /&gt;parent = urlfs[1]&lt;br /&gt;for img_url in parser.urls:&lt;br /&gt;if re.search('\.jpe?g$', img_url):&lt;br /&gt;print "looking at: " + img_url&lt;br /&gt;if not re.match('^http://', img_url):&lt;br /&gt;img_url = 'http://' + parent + '/' + img_url&lt;br /&gt;loc = url_mapper(img_url)&lt;br /&gt;if os.path.exists(loc): continue&lt;br /&gt;url_opener1 = MyURLOpener()&lt;br /&gt;retrieve = url_opener1.retrieve&lt;br /&gt;if loc == '':&lt;br /&gt;print "\turl_mapper returned NULL for " + img_url&lt;br /&gt;continue&lt;br /&gt;loc_dir = re.match('(.+)/.+', loc).group(1)&lt;br /&gt;try:&lt;br /&gt;print('\ttrying to save ' + img_url)&lt;br /&gt;if not os.path.exists(loc_dir):&lt;br /&gt; os.makedirs(loc_dir)&lt;br /&gt;retrieve(img_url, loc)&lt;br /&gt;except IOError:&lt;br /&gt;print('\tSkipping saving ' + img_url)&lt;br /&gt;continue&lt;br /&gt;count += 1&lt;br /&gt;print "\tImg fetched: ",count&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-6279973689533908368?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/vxmcyCROip9NZR3Bvx8A2gU8gpc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vxmcyCROip9NZR3Bvx8A2gU8gpc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/vxmcyCROip9NZR3Bvx8A2gU8gpc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vxmcyCROip9NZR3Bvx8A2gU8gpc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Ak-B_aBVvRM:uZzoWmtu5xA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Ak-B_aBVvRM:uZzoWmtu5xA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Ak-B_aBVvRM:uZzoWmtu5xA:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Ak-B_aBVvRM:uZzoWmtu5xA:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Ak-B_aBVvRM:uZzoWmtu5xA:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/Ak-B_aBVvRM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-13T16:38:13.967+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2009/06/extract-or-reap-images-from-html-web.html</feedburner:origLink></item><item><title>Installing andLinux on Windows Vista</title><link>http://feedproxy.google.com/~r/Techdiary/~3/sVB1iXxSgzg/installing-andlinux-on-windows-vista.html</link><category>problem installing andlinux on Windows Vista</category><category>linux emulator on windows</category><category>andlinux cannot connect to</category><category>Linux on Windows Vista</category><category>andlinux</category><category>Linux on Vista</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Fri, 29 May 2009 08:28:37 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-8028371167936487863</guid><description>After downloading the &lt;a href="http://downloads.sourceforge.net/andlinux/andlinux-beta2-kde.exe"&gt;andLinux installer (KDE version)&lt;/a&gt;, launch the installer as Administrator. And follow the steps with default options set.&lt;br /&gt;&lt;br /&gt;Reboot/Restart machine after installation.&lt;br /&gt;&lt;br /&gt;Click on Unblock if the Firewall prompts.&lt;br /&gt;&lt;br /&gt;After the reboot, you click on Konsole (any) launcher on KDE Menu from system tray, you are likely to get this error "&lt;em&gt;could not launch ... could not connect to&lt;/em&gt; 192.168.11.150"&lt;br /&gt;&lt;br /&gt;So this guide explains how to fix this issue, for the launchers to work on Windows Vista.&lt;br /&gt;&lt;br /&gt;First thing to do is to go to the "Network and Sharing Center" from Control Panel. You can see the "customize" and "view status" links on "Unidentified Network". Click on the "view status", click on properties and double click "Internet Protocol Version 4". That should open up a dialog where you can change the IP and the subnet mask, change the IP to 192.168.10.1 and subnet mask to 255.255.254.0. Click on OK OK ....&lt;br /&gt;&lt;br /&gt;Secondly, open the "andlinux Console" get sudo access and edit the file /etc/network/interfaces.&lt;br /&gt;After edit the file should have IP of 192.168.10.150 and the mask 255.255.254.0 under eth1&lt;br /&gt;&lt;br /&gt;Thirdly edit file /etc/profile to have IPs set to 192.168.10.150&lt;br /&gt;&lt;br /&gt;Fourthly navigate to the andlinux installation folder goto Xming folder edit X0.hosts and add the following IPs 192.168.10.150 and 192.168.10.1&lt;br /&gt;&lt;br /&gt;Lastly few registry changes, regedit and navigate to \\HKEY_LOCAL_MACHINE\\SOFTWARE\\andLinux\\Launcher&lt;br /&gt;Here you find to keys "IP" and "Port" set them to 192.168.10.150 and 2081 respectively.&lt;br /&gt;(Remember to click on Decimal while editing Port value) And close the regedit.&lt;br /&gt;&lt;br /&gt;Finally kill  KDE Menu, Xming. Restart andLinux service, and then start Xming and KDE Menu.&lt;br /&gt;Now the launchers work fine.&lt;br /&gt;&lt;br /&gt;If clicking on a launcher does not start, you open the andLinux Console application and execute:&lt;br /&gt;"/etc/init.d/networking restart". After this any launcher should work fine.&lt;br /&gt;&lt;br /&gt;!Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-8028371167936487863?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GJKiQ7Y4DYyVtjPG6Hsff_mnqdY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GJKiQ7Y4DYyVtjPG6Hsff_mnqdY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GJKiQ7Y4DYyVtjPG6Hsff_mnqdY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GJKiQ7Y4DYyVtjPG6Hsff_mnqdY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=sVB1iXxSgzg:UQCVYst-gNg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=sVB1iXxSgzg:UQCVYst-gNg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=sVB1iXxSgzg:UQCVYst-gNg:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=sVB1iXxSgzg:UQCVYst-gNg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=sVB1iXxSgzg:UQCVYst-gNg:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/sVB1iXxSgzg" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-29T20:58:37.824+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><enclosure url="http://downloads.sourceforge.net/andlinux/andlinux-beta2-kde.exe" length="563097803" type="application/octet-stream" /><media:content url="http://downloads.sourceforge.net/andlinux/andlinux-beta2-kde.exe" fileSize="563097803" type="application/octet-stream" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>After downloading the andLinux installer (KDE version), launch the installer as Administrator. And follow the steps with default options set. Reboot/Restart machine after installation. Click on Unblock if the Firewall prompts. After the reboot, you click </itunes:subtitle><itunes:author>Viki</itunes:author><itunes:summary>After downloading the andLinux installer (KDE version), launch the installer as Administrator. And follow the steps with default options set. Reboot/Restart machine after installation. Click on Unblock if the Firewall prompts. After the reboot, you click on Konsole (any) launcher on KDE Menu from system tray, you are likely to get this error "could not launch ... could not connect to 192.168.11.150" So this guide explains how to fix this issue, for the launchers to work on Windows Vista. First thing to do is to go to the "Network and Sharing Center" from Control Panel. You can see the "customize" and "view status" links on "Unidentified Network". Click on the "view status", click on properties and double click "Internet Protocol Version 4". That should open up a dialog where you can change the IP and the subnet mask, change the IP to 192.168.10.1 and subnet mask to 255.255.254.0. Click on OK OK .... Secondly, open the "andlinux Console" get sudo access and edit the file /etc/network/interfaces. After edit the file should have IP of 192.168.10.150 and the mask 255.255.254.0 under eth1 Thirdly edit file /etc/profile to have IPs set to 192.168.10.150 Fourthly navigate to the andlinux installation folder goto Xming folder edit X0.hosts and add the following IPs 192.168.10.150 and 192.168.10.1 Lastly few registry changes, regedit and navigate to \\HKEY_LOCAL_MACHINE\\SOFTWARE\\andLinux\\Launcher Here you find to keys "IP" and "Port" set them to 192.168.10.150 and 2081 respectively. (Remember to click on Decimal while editing Port value) And close the regedit. Finally kill KDE Menu, Xming. Restart andLinux service, and then start Xming and KDE Menu. Now the launchers work fine. If clicking on a launcher does not start, you open the andLinux Console application and execute: "/etc/init.d/networking restart". After this any launcher should work fine. !Enjoy!</itunes:summary><itunes:keywords>perl,scripting,shell,script</itunes:keywords><feedburner:origLink>http://techdiary-viki.blogspot.com/2009/05/installing-andlinux-on-windows-vista.html</feedburner:origLink></item><item><title>Parsing and Storing parts or paragraphs of log file</title><link>http://feedproxy.google.com/~r/Techdiary/~3/0H0c-xfIUv4/parsing-and-storing-parts-or-paragraphs.html</link><category>Perl Regular Expressions</category><category>regular expression perl Perl regex options</category><category>data extraction</category><category>parse file extract multiple lines</category><category>parsing logs</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Sat, 09 May 2009 07:12:07 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-5271467873355319502</guid><description>At many times we need to parse and store parts of a log file. Suppose an error log, you would like to parse all errors. If the errors span only one line, you could use a grep.&lt;br /&gt;&lt;br /&gt;But if the errors span multiple lines ... you need to put a little logic into your script. There are many ways to do this, but this script that i post here is more readable and can be modified to other's requirement.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=dg2jxmfs_49hjdfdvc9"&gt;Link to the code&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=dg2jxmfs_50gm9mghfj"&gt;Link to a sample input&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the example script i am parsing an error log (named 'input.txt'). The script stores all lines that start with "SQL0204N" till it finds an empty line. Likewise it extracts all errors, even if the error messages span multiple lines.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-5271467873355319502?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ESgcUYohxf4DSICFgL3s_mDaE60/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ESgcUYohxf4DSICFgL3s_mDaE60/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ESgcUYohxf4DSICFgL3s_mDaE60/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ESgcUYohxf4DSICFgL3s_mDaE60/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=0H0c-xfIUv4:P4pCScnCdKY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=0H0c-xfIUv4:P4pCScnCdKY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=0H0c-xfIUv4:P4pCScnCdKY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=0H0c-xfIUv4:P4pCScnCdKY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=0H0c-xfIUv4:P4pCScnCdKY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/0H0c-xfIUv4" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-09T19:42:07.625+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2009/05/parsing-and-storing-parts-or-paragraphs.html</feedburner:origLink></item><item><title>Perl script inside a DOS Batch file</title><link>http://feedproxy.google.com/~r/Techdiary/~3/myMKxf_uKeI/perl-script-inside-dos-batch-file.html</link><author>vikas.nv@gmail.com (Viki)</author><pubDate>Wed, 01 Apr 2009 03:46:03 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-2367434498340904148</guid><description>Whenever I wanted to invoke a utility passing a file as an argument I used to create a shortcut of the utility in the Send To folder, as described here :&lt;br /&gt;&lt;h1 class="title"&gt;&lt;a href="http://support.microsoft.com/kb/310270"&gt;&lt;span style="font-size:100%;"&gt;How to Add Items to the "Send To" Menu&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;But how to have a Perl script in the "Send To" menu??&lt;br /&gt;&lt;br /&gt;I got an idea when browsing through this page :&lt;br /&gt;&lt;h1&gt;&lt;a href="http://www.dostips.com/DtCodeInterfacing.php"&gt;&lt;span style="font-size:100%;"&gt;DOS Batch - Interfacing non DOS Software&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;I created a batch script as described in the page. Then modified the part of the batch file where the Perl script actually starts.&lt;br /&gt;&lt;br /&gt;I wanted to have a utility that can encrypt/decrypt a text file. A basic encryption was sufficient, so considered the &lt;span style="font-weight: bold;"&gt;Caesar cipher.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;I completed the script and added it to the Send To menu&lt;span style="font-weight: bold;"&gt;.&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;a style="font-family: georgia;" href="http://docs.google.com/Doc?id=dg2jxmfs_46frvwj43t"&gt;Link to the script&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: georgia;"&gt;&lt;span&gt;A small modification to the above script to handle binary files. &lt;a href="http://docs.google.com/Doc?id=dg2jxmfs_47gchnbgfc"&gt;Here is the link.&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&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/3366815763976900792-2367434498340904148?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/u4_jBdg1qQk3nzAzeLkbgh7IErY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/u4_jBdg1qQk3nzAzeLkbgh7IErY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/u4_jBdg1qQk3nzAzeLkbgh7IErY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/u4_jBdg1qQk3nzAzeLkbgh7IErY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=myMKxf_uKeI:3G1RPRhN93c:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=myMKxf_uKeI:3G1RPRhN93c:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=myMKxf_uKeI:3G1RPRhN93c:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=myMKxf_uKeI:3G1RPRhN93c:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=myMKxf_uKeI:3G1RPRhN93c:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/myMKxf_uKeI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-01T16:16:03.371+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2009/04/perl-script-inside-dos-batch-file.html</feedburner:origLink></item><item><title>andLinux   ---    Run Linux from Windows</title><link>http://feedproxy.google.com/~r/Techdiary/~3/SG-ZkXKvILA/andlinux-run-linux-from-windows.html</link><category>linux from windows</category><category>emulated PC software</category><category>use windows and linux parallely</category><category>emulated Linux</category><category>parallel OS</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Sat, 13 Dec 2008 09:28:55 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-5498531799646678577</guid><description>Have you ever had a feeling of using Linux when you are working on Windows???&lt;div&gt;Or&lt;/div&gt;&lt;div&gt;Felt like using those very useful Linux commands fromWindows???&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is possible ...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Everybody knows that you can have a Dual-Boot on your PC with Linux &amp;amp; Windows. In which you have to restart the PC to access the other OS. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But there are several other ways to have Other OS run right from Windows, that is for example use Linux when you have logged on to Windows... Yes... Virtual Machines (also popular as VM) is one of them. But running a VM requires that your hardware to be really good.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There is one more option, we now have emulated PC software like &lt;a href="http://www.andlinux.org/"&gt;andLinux&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are many other softwares other than andLinux, such as CygwinX, MKS Toolkit, etc&lt;/div&gt;&lt;div&gt;But I found andLinux to be really very handy, straight-forward &amp;amp; useful.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Installing andLinux is as simple as installing other software ... clikcing Next, Next, Next ... &amp;amp; finnaly Finish :) there is a very &lt;a href="http://www.andlinux.org/install.php"&gt;elaborate tutorial&lt;/a&gt; on its web site&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However if you are the curious cat... you can also fiddle around &amp;amp; do the installation without the tutorial.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The home page of andLinux says &lt;span class="Apple-style-span" style="font-style: italic;"&gt;"a&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;ndLinux is not just for development and runs almost all Linux applications without modification&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-family:Georgia;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;". &lt;/span&gt;I have installed a lot many applications to andLinux, and its really true.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After installation you can see the icons of andLinux in system tray. You may see these icons :&lt;/div&gt;&lt;div&gt;KDE menu (andLinux)&lt;/div&gt;&lt;div&gt;Xming (andLinux)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While installing say you choose E: drive as destination. It gets installled in a folder E:\andLinux.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It will create some folders &amp;amp; files in E:\andLinux, I will list some folders &amp;amp; files with thier &lt;span class="Apple-style-span"  style="font-size:medium;"&gt;purposes:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;1. settings.txt, a plain-text file that will have some paths necessary for andLinux to work properly&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;2. srvstart.bat, batch file, that has the command to start the andLinux service&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;3. srvstop.bat, batch file, has the command to stop andLinux service&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;4. startup.bat, again a batch file used to start the andLinux as deamon&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;5. Drives, directory, where the andLinux's filesystem is stored as files (base.drv, mine is 4GB in size and swap.drv)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6. Launcher, directory, where all the executables can be seen. A good place to check out what all linux apps you get after installing andLinux.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;7. There are other directories as well, netdriver, pulseaudio &amp;amp; Xming&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;One application that is very usefull after installing andLinux is the &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;synaptic.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt; It is the application manager of andLinux. You can find this from KDE Menu / open a terminal &amp;amp; type &lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;synaptic.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There is a huge collection of linux applications that you can select &amp;amp; install. As i feel the GUI is staright-forward &amp;amp; easy to understand, compared to CygwinX. It is more responsive on my machine with 512 MB of RAM &amp;amp; Dual Core Intel.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is still in Beta, you can go to the &lt;a href="http://www.andlinux.org/downloads.php"&gt;andLinux&lt;/a&gt; website to download it. There is a &lt;a href="http://linuxtracker.org/index.php?page=torrents&amp;amp;category=466"&gt;torrent tracker&lt;/a&gt; also.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;EnJoy ...&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-5498531799646678577?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/27HlSeJ6WHuy8jipNKguSZrhfVk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/27HlSeJ6WHuy8jipNKguSZrhfVk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/27HlSeJ6WHuy8jipNKguSZrhfVk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/27HlSeJ6WHuy8jipNKguSZrhfVk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SG-ZkXKvILA:Zzq8k5aWkOM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SG-ZkXKvILA:Zzq8k5aWkOM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SG-ZkXKvILA:Zzq8k5aWkOM:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SG-ZkXKvILA:Zzq8k5aWkOM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SG-ZkXKvILA:Zzq8k5aWkOM:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/SG-ZkXKvILA" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-13T22:58:55.227+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/12/andlinux-run-linux-from-windows.html</feedburner:origLink></item><item><title>Script to comment parts of code in a source file</title><link>http://feedproxy.google.com/~r/Techdiary/~3/3ktrGqUqVCY/script-to-comment-parts-of-code-in.html</link><category>comment source code</category><category>comment other scripts</category><category>commenting script</category><category>script to comment source files</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Sat, 13 Dec 2008 08:41:50 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-109124640280445146</guid><description>&lt;div&gt;A friend of mine wanted a script to comment parts of code in a source file. We were chatting &amp;amp; i gave him this solution:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;me: perl --i.bak -pe 's/^(.*)$/#$1/gi if ($. &gt;=start_line_number &amp;amp;&amp;amp; $. &lt;= end_line_number)' filename&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;Try above command in terminal. Where start_line_number is the line number where u shud start commenting &amp;amp; end_line_number is where u want to stop commenting.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But he wanted that the script should take a function name as input rather than line numbers ... this is what he says: (name not published ;))&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;myfrend: hey vikas, i need a script to start commenting the codes without using line numbers, but using function name....is it possible?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;me: u mean to say u have function names ... &amp;amp; u want to comment the whole functions?&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;u mean to say u have function names ... &amp;amp; u want to comment the whole functions?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;myfrend: yeah&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;me: it is possible ... if u can get correct start&amp;amp;end boundaries for the functions&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;myfrend: yeah..how to get it....its difficult&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;me: how big can the file be .. that is MAX big file size?&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;myfrend: say around 3000 lines&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was asking a lot of questions about the source files like do they follow coding standards, etc .. &amp;amp; all that. So he suggested what he wanted to do ... i mean the logic ... he said:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;myfrend: my logic is : search for function name, then keep a counter to increment/decrement when { or } is found, when counter is zero, exit the prgm&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;me: this is holds good ... but u have to account for { } occuring on same line ... &amp;amp; account for comments, etc&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;myfrend: ok&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Got some free time to think about it ... &amp;amp; wrote a script for this. This may not be a complete solution, but a good starting point i guess.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is the link to the script:&lt;/div&gt;&lt;div&gt;&lt;a id="publishedDocumentUrl" class="tabcontent" target="_blank" href="http://docs.google.com/Doc?id=dg2jxmfs_43gbtd2jfq"&gt;http://docs.google.com/Doc?id=dg2jxmfs_43gbtd2jfq&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;PS - myfrend :&lt;div&gt;If you permit I can publish your name ... with a hyperlink possibly to your blog ;)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-109124640280445146?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/j-OIuhj60ef7mFAzI4VdE75CEFc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j-OIuhj60ef7mFAzI4VdE75CEFc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/j-OIuhj60ef7mFAzI4VdE75CEFc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j-OIuhj60ef7mFAzI4VdE75CEFc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=3ktrGqUqVCY:D2_EL165MqU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=3ktrGqUqVCY:D2_EL165MqU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=3ktrGqUqVCY:D2_EL165MqU:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=3ktrGqUqVCY:D2_EL165MqU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=3ktrGqUqVCY:D2_EL165MqU:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/3ktrGqUqVCY" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-13T22:11:50.828+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/12/script-to-comment-parts-of-code-in.html</feedburner:origLink></item><item><title>Get Spiritual ...</title><link>http://feedproxy.google.com/~r/Techdiary/~3/jlkC__CrTZA/get-spiritual.html</link><category>temples</category><category>photo gallaries</category><category>vatsa</category><category>srivatsa shroff's photo galleries</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Thu, 21 Aug 2008 04:41:45 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-2113603536724058090</guid><description>Get spiritual ...&lt;br /&gt;&lt;br /&gt;Take a look at the photo galleries shared by my good friend in his blog.&lt;br /&gt;&lt;br /&gt;http://srivatsashroff.blogspot.com&lt;br /&gt;&lt;br /&gt;Notice lot of temples in the galleries, that is all with getting spiritual :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PS: Obviously, this is post has nothing to do with Perl | ;) |&lt;br /&gt;Viki&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-2113603536724058090?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-eSG9clrWsIzTkt4FaAbbiVa5qE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-eSG9clrWsIzTkt4FaAbbiVa5qE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-eSG9clrWsIzTkt4FaAbbiVa5qE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-eSG9clrWsIzTkt4FaAbbiVa5qE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=jlkC__CrTZA:xqw1ohoSatY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=jlkC__CrTZA:xqw1ohoSatY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=jlkC__CrTZA:xqw1ohoSatY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=jlkC__CrTZA:xqw1ohoSatY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=jlkC__CrTZA:xqw1ohoSatY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/jlkC__CrTZA" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-21T17:11:45.842+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/08/get-spiritual.html</feedburner:origLink></item><item><title>Example for use of grep(), map() and readdir()</title><link>http://feedproxy.google.com/~r/Techdiary/~3/nykuYk3P7Rk/example-for-use-of-grep-map-and-readdir.html</link><category>example for reading directory contents using readdir() in Perl</category><category>example for Perl map</category><category>use of Perl readdir()</category><category>example for Perl grep</category><category>reading directory contents</category><category>use of Perl map {}</category><category>use of Perl grep {}</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Tue, 28 Oct 2008 07:49:38 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-6956100978769031771</guid><description>You should have used readdir() to read contents of a directory. For that you have to open a directory as in:&lt;br /&gt;&lt;br /&gt;opendir(DIR, "$directory_path");&lt;br /&gt;&lt;br /&gt;After which readdir(DIR) returns an entry or all directory entries depending on the context.&lt;br /&gt;&lt;br /&gt;my $file = readdir(DIR); # returns only single entry&lt;br /&gt;my @files = readdir(DIR); # returns all the directory entries&lt;br /&gt;&lt;br /&gt;But the values returned will not have the absolute path. For this reason, I use map to prefix the path for each entry ...&lt;br /&gt;&lt;br /&gt;my @files = map { "$directory_path/$_" } readdir(DIR);&lt;br /&gt;&lt;br /&gt;Now using the code given above all directory entries will have absolute paths.&lt;br /&gt;&lt;br /&gt;If you want to grep for a pattern &amp;amp; collect only those entries that match a pattern use grep {}, like this:&lt;br /&gt;&lt;br /&gt;my @files = grep { /pattern/ } map { "$directory_path/$_" } readdir(DIR);&lt;br /&gt;&lt;br /&gt;In the above example, using grep {} before or after map {} makes a difference.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-6956100978769031771?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/iwwHRziS_REDxCWSVlGG2o2Vphc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iwwHRziS_REDxCWSVlGG2o2Vphc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/iwwHRziS_REDxCWSVlGG2o2Vphc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iwwHRziS_REDxCWSVlGG2o2Vphc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=nykuYk3P7Rk:Gs1ukkmUEJU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=nykuYk3P7Rk:Gs1ukkmUEJU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=nykuYk3P7Rk:Gs1ukkmUEJU:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=nykuYk3P7Rk:Gs1ukkmUEJU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=nykuYk3P7Rk:Gs1ukkmUEJU:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/nykuYk3P7Rk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-28T20:19:38.415+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/08/example-for-use-of-grep-map-and-readdir.html</feedburner:origLink></item><item><title>Sockets ... not the electrical ones ;)</title><link>http://feedproxy.google.com/~r/Techdiary/~3/viyDN8HEReI/sockets-not-electrical-ones.html</link><author>vikas.nv@gmail.com (Viki)</author><pubDate>Sat, 16 Aug 2008 07:56:38 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-8272658834988387078</guid><description>&lt;span style="font-family:verdana;"&gt;This is my first script that used Sockets. Written around 2 years back, when I was still learning the various uses of Perl. Was very excited to see this work ... Check out the files :&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The server script:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=dg2jxmfs_42hcxtq3fv"&gt;&lt;span style="font-family:verdana;"&gt;http://docs.google.com/Doc?id=dg2jxmfs_42hcxtq3fv&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;THe client script:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=dg2jxmfs_41cvcnk6d5"&gt;&lt;span style="font-family:verdana;"&gt;http://docs.google.com/Doc?id=dg2jxmfs_41cvcnk6d5&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Comments, questions ... welcome !&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-8272658834988387078?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zj497gbPWbqWBTG0kOXDMef9Muc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zj497gbPWbqWBTG0kOXDMef9Muc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zj497gbPWbqWBTG0kOXDMef9Muc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zj497gbPWbqWBTG0kOXDMef9Muc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=viyDN8HEReI:Bs6uvUpuHvY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=viyDN8HEReI:Bs6uvUpuHvY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=viyDN8HEReI:Bs6uvUpuHvY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=viyDN8HEReI:Bs6uvUpuHvY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=viyDN8HEReI:Bs6uvUpuHvY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/viyDN8HEReI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-16T20:26:38.860+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/08/sockets-not-electrical-ones.html</feedburner:origLink></item><item><title>When data stored becomes very large ...</title><link>http://feedproxy.google.com/~r/Techdiary/~3/bJpGcuhLz_A/when-data-stored-becomes-very-large.html</link><category>very large memory used to store data in variables data structures</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Tue, 05 Aug 2008 07:51:11 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-5392499358568093079</guid><description>&lt;span style="font-family: verdana;"&gt;There will be situations at which the data you store in memory (variables) is huge, &amp;amp; the script cribbs &amp;amp; might throw "Out of memory" error (happens if the available memory is very low) &amp;amp; exit.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;This had happened to me when extracting large amount of data &amp;amp; storing it into a data structure. The actual reason for this was not the data structure itself, but because of an array in which I used to read the entire files' contents (~35MB/file). The issue was solved once I started reading the file line-by-line.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;That was just a part of the topic I wanted to write here... Actually, in the process of lowering the memory usage I had used some new (at least, its new for me)  techniques of storing numerical data &amp;amp; that's what I want to write here.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;This is the data structure that I had used:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;%hash =  {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;                          "key1"  =&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;                                                        "kkey1"  =&gt;   "vvalue1"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;                                                          ...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;                                                },&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;                           ...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;So that's the pictorial of my data structure. In this I had to store some numbers that had to be paired (there was a relationship b/w them) &amp;amp; also for these numbers I had to calculate the average &amp;amp; median. The number-pairs found to be larger than 999, so I had to use a glue character b/w then number-pair &amp;amp; store as "kkey1" &amp;amp; store the number of occurrences as the "vvalue1".&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Since it was average &amp;amp; median to be calculated... I wrote these two neat subroutines:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;sub get_average {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my (%input_cnt) = @_;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my $count = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my $sum = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    foreach my $input (keys %input_cnt) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        $sum += ($input*$input_cnt{$input});&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    foreach my $cnt (values %input_cnt) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        $count += $cnt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my $average = $sum/$count;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    return $average;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;sub get_median {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my (%inputs_cnt) = @_;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my @sorted = sort { $a &lt;=&gt; $b } keys %inputs_cnt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my %sorted_vals_index = ();        #    sorted_vals_index{delay}  =&gt;  'low_index:high_index'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my $index = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    foreach my $ele (@sorted) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        my $h_i = $index + ($inputs_cnt{$ele}-1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        $sorted_vals_index{$ele} = "$index:$h_i";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        $index = $h_i+1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    my $mid_index = ($index-1)/2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    foreach my $ele (keys %sorted_vals_index) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        my ($l_i, $h_i) = ($sorted_vals_index{$ele} =~ /(.+?):(.+)/);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        if (($mid_index &gt;= $l_i) &amp;amp;&amp;amp; ($mid_index &lt;= $h_i)) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;            return $ele;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Each subroutine takes a hash, where the key is the number &amp;amp; value is the number of occurrences.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;So the memory used became very less, since I avoided storing duplicate number-pairs.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-5392499358568093079?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W6IGaUM3lgn08qQyLr-AbEqYO9s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W6IGaUM3lgn08qQyLr-AbEqYO9s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W6IGaUM3lgn08qQyLr-AbEqYO9s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W6IGaUM3lgn08qQyLr-AbEqYO9s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=bJpGcuhLz_A:jScuirHGIKU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=bJpGcuhLz_A:jScuirHGIKU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=bJpGcuhLz_A:jScuirHGIKU:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=bJpGcuhLz_A:jScuirHGIKU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=bJpGcuhLz_A:jScuirHGIKU:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/bJpGcuhLz_A" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-05T20:21:11.036+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/08/when-data-stored-becomes-very-large.html</feedburner:origLink></item><item><title>Regular Expressions (more)</title><link>http://feedproxy.google.com/~r/Techdiary/~3/1uIc8Dm-Zrw/regular-expressions-more.html</link><category>regular expression perl Perl regex options</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:52:03 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-1947803384348689297</guid><description>&lt;span style="font-family:verdana;"&gt;There are many more options that can be used with PERL regular expressions.&lt;br /&gt;&lt;br /&gt;The different options that I have used are: g,i,s,m,o,x&lt;br /&gt;These options are to be specified like this:&lt;br /&gt;/reg-exp/options&lt;br /&gt;One or more options can be used, but one cant' use s &amp;amp; m simultaneously.&lt;br /&gt;&lt;br /&gt;So here are the meanings of these regular expressions ...&lt;br /&gt;&lt;br /&gt;g -&gt; Match Globally:&lt;br /&gt;This option can be used when you are trying to match a pattern in the whole string. As in this example :&lt;br /&gt;&lt;span style="font-style: italic;"&gt;$you_appeared++ while(/\s+you\s+/g);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;i -&gt; Ignore Case:&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;Use this when case of the pattern does not matter.&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;s -&gt; Treat Workspace As Single Line&lt;span style="font-style: italic;"&gt;:&lt;br /&gt;&lt;/span&gt;This option is used when you need to match "\n" with reg-exp special character '.'&lt;span style="font-style: italic;"&gt;. &lt;/span&gt;Or put simpl&lt;span style="font-style: italic;"&gt;e&lt;/span&gt;, you this option when the work space has "\n"'s and you want to match something considering "\n".&lt;span style="font-style: italic;"&gt;&lt;br /&gt;my $workspace = "I'am sure you are confused\nYou have to use it to understand it\n";&lt;br /&gt;if ($workspace =~ /use/s) {&lt;br /&gt;print "$&amp;amp;$'\n";&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;span&gt;m -&gt; Treat workspace as multiple lines. This option differs from above, here '.' does not match a "\n" however, treats workspace as multiple lines.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;span&gt;o -&gt; compile the pattern once. The effect this produces is visible when you use a variable. Since the pattern is compiled only once, the variable will be replaced only once in the pattern - no matter how many times the pattern is used.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Verdana;"&gt;x -&gt; add comments inside the regexp, using '#'&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:Verdana;"&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/3366815763976900792-1947803384348689297?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BG-ThkHAzJvzsHRRyRLA8m4jp0I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BG-ThkHAzJvzsHRRyRLA8m4jp0I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BG-ThkHAzJvzsHRRyRLA8m4jp0I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BG-ThkHAzJvzsHRRyRLA8m4jp0I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=1uIc8Dm-Zrw:6ExOZQ9lRAo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=1uIc8Dm-Zrw:6ExOZQ9lRAo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=1uIc8Dm-Zrw:6ExOZQ9lRAo:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=1uIc8Dm-Zrw:6ExOZQ9lRAo:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=1uIc8Dm-Zrw:6ExOZQ9lRAo:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/1uIc8Dm-Zrw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:22:03.607+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/regular-expressions-more.html</feedburner:origLink></item><item><title>Reading ... Processing file paragraph by paragraph</title><link>http://feedproxy.google.com/~r/Techdiary/~3/cJDbVMrr47o/reading-file-paragraph-by-paragraph.html</link><category>perl read files in paragraph mode</category><category>paragraph by paragraph</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Sat, 09 May 2009 06:27:02 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-5337814817276573831</guid><description>&lt;span style="font-family:verdana;"&gt;There are many situations you may want to process a text file paragraph by paragraph ...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;One such example was this, I wanted to delete those paragraphs from a text file that had a particular pattern. Like, delete all paragraphs that has text like 'copyright protected by blah blah'.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;First thing is to learn how to read a text file paragraph by paragraph, for that we will see how to open a file (named web_extract.txt):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;open (FILE, "web_extract.txt") or die "Unable to open web_extract.txt: $!\n";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This is how you can read the opened file line by line:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;while(my $line = &amp;lt;FILE&amp;gt; ) {&lt;br /&gt;             .... do something ...&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;But to read a file in paragraph mode, you have to reset (zero) the special variable $/, look at the code below:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;{&lt;br /&gt;       local $/ = &amp;#39;&amp;#39;;&lt;br /&gt;       @paragraphs = &amp;lt;FILE&amp;gt;;&lt;br /&gt;       chomp @paragraphs;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;So this will read the opened file in paragraph mode.&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Don't worry about the block, it is used to localize resetting the $/ variable&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Now the variable @paragraphs has paragraphs as its elements. So you can loop around this variable and push the elements (to @filtered_paragraphs) that do not match your pattern. Then print that new array (@filtered_paragraphs) to the (same/another) file.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Done!!!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-5337814817276573831?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CXs1KORRidFyZpF1I_okvQzAxVM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CXs1KORRidFyZpF1I_okvQzAxVM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CXs1KORRidFyZpF1I_okvQzAxVM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CXs1KORRidFyZpF1I_okvQzAxVM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=cJDbVMrr47o:e0cHWCXHq_w:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=cJDbVMrr47o:e0cHWCXHq_w:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=cJDbVMrr47o:e0cHWCXHq_w:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=cJDbVMrr47o:e0cHWCXHq_w:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=cJDbVMrr47o:e0cHWCXHq_w:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/cJDbVMrr47o" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-09T18:57:02.272+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/reading-file-paragraph-by-paragraph.html</feedburner:origLink></item><item><title>To check the lists of file created between X-Y minutes</title><link>http://feedproxy.google.com/~r/Techdiary/~3/tjljesfAckM/to-check-lists-of-file-created-between.html</link><category>collect files</category><category>perl script to find files created between</category><category>files that were created</category><category>files created or modified between</category><category>what files were created or modified</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:10:10 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-6030916642908375276</guid><description>I have seen many questions on this -&gt;&lt;br /&gt;&lt;br /&gt;how to get a list of files that were created/modified between 30 to 60 minutes? or 1 to 2 hours ... etc.&lt;br /&gt;&lt;br /&gt;Here is a simple PERL script to do this job:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;use strict;&lt;br /&gt;use File::Find;&lt;br /&gt;&lt;br /&gt;my $path_to_start = $ARGV[0];&lt;br /&gt;my @files_bet_30_60 = ();&lt;br /&gt;my $thirty_mins_in_secs = 30*60;      # change the value of this var to decrease the lower limit&lt;br /&gt;my $sixty_mins_in_secs = 60*60;     # change the value if this var to increase the upper limit&lt;br /&gt;&lt;br /&gt;finddepth(\&amp;amp;wanted, $path_to_start);&lt;br /&gt;foreach my $file (@files_bet_30_60) {&lt;br /&gt;         print "$file\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub wanted {&lt;br /&gt;       my $file = $File::Find::name;&lt;br /&gt;       next unless (-f $file);&lt;br /&gt;&lt;br /&gt;        my $mtime = (stat($file))[9];&lt;br /&gt;       my $time_diff = time - $mtime;&lt;br /&gt;   push @files_bet_30_60, $file if (($time_diff &gt; $thirty_mins_in_secs) &amp;amp;&amp;amp; ($time_diff &lt; $sixty_mins_in_secs)); }  &lt;/span&gt;&lt;span&gt;Also following &lt;/span&gt;&lt;span&gt;shell command &lt;/span&gt;&lt;span&gt;can do&lt;/span&gt;&lt;span&gt; this:&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;find /path/to/files -type f \( -newer min60 -a ! -newer min30 \)&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/3366815763976900792-6030916642908375276?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/C7Ioz1373g1uOtVAZJMWVvHuhbI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C7Ioz1373g1uOtVAZJMWVvHuhbI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/C7Ioz1373g1uOtVAZJMWVvHuhbI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C7Ioz1373g1uOtVAZJMWVvHuhbI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tjljesfAckM:uX5AAWCq78k:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tjljesfAckM:uX5AAWCq78k:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tjljesfAckM:uX5AAWCq78k:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tjljesfAckM:uX5AAWCq78k:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tjljesfAckM:uX5AAWCq78k:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/tjljesfAckM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:40:10.636+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/to-check-lists-of-file-created-between.html</feedburner:origLink></item><item><title>Video: PERL tutorial that I found on YouTube</title><link>http://feedproxy.google.com/~r/Techdiary/~3/qU1R0WK4r2c/video-perl-tutorial-that-i-found-on_17.html</link><category>Perl Video tutorials</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:55:16 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-5286705935151746586</guid><description>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/p/E7511681ABEA8635"&gt;&lt;embed src="http://www.youtube.com/p/E7511681ABEA8635" type="application/x-shockwave-flash" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-5286705935151746586?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jMBY5qlCGuFQO4gZ4_ItYDfJqbE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jMBY5qlCGuFQO4gZ4_ItYDfJqbE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jMBY5qlCGuFQO4gZ4_ItYDfJqbE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jMBY5qlCGuFQO4gZ4_ItYDfJqbE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=qU1R0WK4r2c:qsDyhsWrmXY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=qU1R0WK4r2c:qsDyhsWrmXY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=qU1R0WK4r2c:qsDyhsWrmXY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=qU1R0WK4r2c:qsDyhsWrmXY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=qU1R0WK4r2c:qsDyhsWrmXY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/qU1R0WK4r2c" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:25:16.102+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><enclosure url="http://www.youtube.com/p/E7511681ABEA8635" length="763" type="application/x-shockwave-flash" /><media:content url="http://www.youtube.com/p/E7511681ABEA8635" fileSize="763" type="application/x-shockwave-flash" /><itunes:explicit>no</itunes:explicit><itunes:author>Viki</itunes:author><itunes:keywords>perl,scripting,shell,script</itunes:keywords><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/video-perl-tutorial-that-i-found-on_17.html</feedburner:origLink></item><item><title>Video Playlist: PERL tutorials that I found on YouTube</title><link>http://feedproxy.google.com/~r/Techdiary/~3/SZcEHJ5hwTk/video-perl-tutorial-that-i-found-on.html</link><category>Perl Video tutorials</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:54:43 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-8143299960569988555</guid><description>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/p/E7511681ABEA8635"&gt;&lt;embed src="http://www.youtube.com/p/E7511681ABEA8635" type="application/x-shockwave-flash" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-8143299960569988555?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xrANyMgjzPE5FfCUrOYCp9SJ2Gs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xrANyMgjzPE5FfCUrOYCp9SJ2Gs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xrANyMgjzPE5FfCUrOYCp9SJ2Gs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xrANyMgjzPE5FfCUrOYCp9SJ2Gs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SZcEHJ5hwTk:07GmsCC4RyI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SZcEHJ5hwTk:07GmsCC4RyI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SZcEHJ5hwTk:07GmsCC4RyI:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=SZcEHJ5hwTk:07GmsCC4RyI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=SZcEHJ5hwTk:07GmsCC4RyI:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/SZcEHJ5hwTk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:24:43.470+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><enclosure url="http://www.youtube.com/p/E7511681ABEA8635" length="763" type="application/x-shockwave-flash" /><media:content url="http://www.youtube.com/p/E7511681ABEA8635" fileSize="763" type="application/x-shockwave-flash" /><itunes:explicit>no</itunes:explicit><itunes:author>Viki</itunes:author><itunes:keywords>perl,scripting,shell,script</itunes:keywords><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/video-perl-tutorial-that-i-found-on.html</feedburner:origLink></item><item><title>PERL script to check if a process is alive</title><link>http://feedproxy.google.com/~r/Techdiary/~3/Qkt7xqM_bPI/perl-script-to-check-if-process-is.html</link><category>process check</category><category>check if a process is alive else execute it</category><category>check if process is open</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:07:46 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-8729969405795992674</guid><description>&lt;span style="font-family:verdana;"&gt;Below i have a perl script that checks if a given process (passed as command-line argument) is alive or not. If the process had died for some reason, it re-invokes it.&lt;br /&gt;&lt;br /&gt;Put this in crontab &amp;amp; schedule it to run every 1 hour or so.&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; This will take to keep your ever running processes alive&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;The script:&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;br /&gt;#!/usr/bin/perl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;my $process_to_check = $ARGV[0] or die "Usage: $0 &lt;full-path&gt;\n";&lt;/full-path&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;open(PS,"/bin/ps -aef|") || die "Can't Open PS: $!\n";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;while(&lt;ps&gt;) {&lt;/ps&gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="font-style: italic;font-family:verdana;" &gt;chomp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;          if (/\Q$process_to_check\E/) { close PS; exit;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;close PS;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;system("&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;$process_to_check&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;");&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-8729969405795992674?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/J99tJ8h4n1qZLM8JJT22gbv-6EE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J99tJ8h4n1qZLM8JJT22gbv-6EE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/J99tJ8h4n1qZLM8JJT22gbv-6EE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J99tJ8h4n1qZLM8JJT22gbv-6EE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Qkt7xqM_bPI:QI3-xht14eM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Qkt7xqM_bPI:QI3-xht14eM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Qkt7xqM_bPI:QI3-xht14eM:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=Qkt7xqM_bPI:QI3-xht14eM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=Qkt7xqM_bPI:QI3-xht14eM:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/Qkt7xqM_bPI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:37:46.503+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/perl-script-to-check-if-process-is.html</feedburner:origLink></item><item><title>Collect files that were created/modified in last 30 to 60 minutes</title><link>http://feedproxy.google.com/~r/Techdiary/~3/OqNYOO5FNE0/collect-files-that-were-createdmodified.html</link><category>perl script to find files created between</category><category>files created or modified between</category><category>collect files that were created in last N minutes</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:57:46 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-4141039262276951684</guid><description>&lt;span style="font-family:verdana;"&gt;I actually wrote this script in reply to a &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://www.unix.com/shell-programming-scripting/73429-check-lists-file-created-between-30-60-min.html"&gt;post&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This is what it does ...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Given a path (as command-line argument), the script will search through the file system &amp;amp; lists the files that were created/modified in last 30-60 minutes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The script:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;use strict;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; use File::Find;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; my $path_to_start = $ARGV[0];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; my @files_bet_30_60 = ();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; my $thirty_mins_in_secs = 30*60;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; my $sixty_mins_in_secs = 60*60;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; finddepth(\&amp;amp;wanted, $path_to_start);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; foreach my $file (@files_bet_30_60) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;               print "$file\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; sub wanted {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;              my $file = $File::Find::name;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;             next unless (-f $file);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;            my $mtime = (stat($file))[9];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;             my $time_diff = time - $mtime;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;             push @files_bet_30_60, $file if &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;                      (($time_diff &gt; $thirty_mins_in_secs) &amp;amp;&amp;amp; ($time_diff &lt; $sixty_mins_in_secs));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; }&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-4141039262276951684?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/FxXIxPVqLbiCsFpsGAsB1soJvIQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FxXIxPVqLbiCsFpsGAsB1soJvIQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/FxXIxPVqLbiCsFpsGAsB1soJvIQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FxXIxPVqLbiCsFpsGAsB1soJvIQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=OqNYOO5FNE0:wLLWvPONoW8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=OqNYOO5FNE0:wLLWvPONoW8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=OqNYOO5FNE0:wLLWvPONoW8:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=OqNYOO5FNE0:wLLWvPONoW8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=OqNYOO5FNE0:wLLWvPONoW8:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/OqNYOO5FNE0" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:27:46.420+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/collect-files-that-were-createdmodified.html</feedburner:origLink></item><item><title>A Little Guide to PERL Regular Expressions</title><link>http://feedproxy.google.com/~r/Techdiary/~3/iNofhDA3OUk/little-guide-to-perl-regular.html</link><category>Perl Regular Expressions</category><category>Perl regex guide</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:58:19 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-9018087789864856808</guid><description>&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;Why RegExp?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Regular Expressions are powerful tools for pattern matching and it is also PERL’s powerful tool.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;Starting with Regular Expressions:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Before introducing to Regular Expression, we shall see what is &lt;span style="font-style: italic;"&gt;$_&lt;/span&gt; and how it is relevant to regular expressions.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;$_&lt;/span&gt; is a PERL special variable which is the default workspace for the regular expression operator.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;However, &lt;span style="font-style: italic;"&gt;$_&lt;/span&gt; is also the default workspace for many commands in PERL. For example, if you just say &lt;span style="font-style: italic;"&gt;print&lt;/span&gt; in your script it would print the contents in &lt;span style="font-style: italic;"&gt;$_&lt;/span&gt;, same with &lt;span style="font-style: italic;"&gt;chop, chomp&lt;/span&gt;, etc.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Coming back to our topic, we shall start with the pattern match operator of PERL &lt;span style="font-style: italic;"&gt;/pattern/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;It is as “powerful” as “simple to see”.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;/pattern/&lt;/span&gt; can be used if the workspace of regular expression is $_. If you want to match a pattern against a variable then the operator is &lt;span style="font-style: italic;"&gt;$variable =~ /pattern/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Let us see some simple regular expressions examples:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;1.    Match vikas in this line “my name is vikas”:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;       &lt;span style="font-style: italic;"&gt;$variable = “my name is vikas”;   # variable to match&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;       $variable =~ /vikas/;                      # matching the pattern ‘vikas’ in &lt;/span&gt;$variable&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;2.    The above example if workspace is $_:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; &lt;span style="font-style: italic;"&gt;      $_ = “my name is vikas”;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;       /vikas/;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;How to use this actually?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;These operators can be used with if, while &amp;amp; even foreach constructs. I will explain the usage with an example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;Scenario:    [Extracting data by matching a pattern from a log file]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Say you have a log file that saved your chat &amp;amp; it is important to get all your friend’s chat ids. The log is very big … maybe because it logs all sessions in a single file.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;With that story told … you decide to use regular expressions to extract that all the chat ids.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Now all that you have to do is to get a pattern from the log, which you will have to match … You open the file &amp;amp; you see this line:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;##### Start of chat with xyz@bahoo at 05:00 PM 25-01-08 #####&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;For every chat above format is repeated. So your pattern can be:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;/^\s*#+\s+ Start of chat with\s+(\w+\@\w+)\s+/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This pattern uses many other RegExp &lt;span style="font-style: italic;"&gt;anchor characters, repetitions, braces &amp;amp; character classes&lt;/span&gt; which I will explain.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;So … here are the &lt;span style="font-weight: bold;"&gt;anchor characters&lt;/span&gt; that you can use:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;^ Or \A&lt;/span&gt;             Match beginning of the string/line -- used in my example&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;$ Or \Z&lt;/span&gt;             Match end of the string/line&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;\z&lt;/span&gt;                    End of string in any match mode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;\b&lt;/span&gt;                    Match word boundary&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;\B&lt;/span&gt;                    Match non-word boundary&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Here are the &lt;span style="font-weight: bold;"&gt;repetition characters&lt;/span&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;?&lt;/span&gt;     Zero or one occurrence of the previous item&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;* &lt;/span&gt;    Zero or more occurrences of the previous item – used in my example&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;+&lt;/span&gt;    One or more occurrences of the previous item – used in my example&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;There is more repetition operators, which I do not want to, put up here.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Here are the &lt;span style="font-weight: bold;"&gt;braces/capturing groups&lt;/span&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;(...)&lt;/span&gt;    Group several characters together for later use or capture as a single unit, and the matched values will be stored in special variables named $1, $2, $3 …&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;All this said, we will move on to our example &amp;amp; look at the code:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;# first open the log file&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;open (LOG, ”chat. log”) or die “Unable to open chat.log: $!\n”;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;my @all_contents = &lt;log&gt;;    # read all contents into an array&lt;/log&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;close LOG;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;foreach my $line (@all_contents) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;    if ($line =~ /^\s*#+\s+ Start of chat with\s+(\w+\@\w+)\s+/) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;        print ”$1\n”;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The above script will print all the chat ids that the log contains. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;For more about regular expressions visit this link: &lt;a href="http://perldoc.perl.org/perlre.html"&gt;http://perldoc.perl.org/perlre.html&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-9018087789864856808?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/68N2P9p5f_7HnxCkvQHwH6jhbMY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/68N2P9p5f_7HnxCkvQHwH6jhbMY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/68N2P9p5f_7HnxCkvQHwH6jhbMY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/68N2P9p5f_7HnxCkvQHwH6jhbMY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=iNofhDA3OUk:_X3i9-0N2MU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=iNofhDA3OUk:_X3i9-0N2MU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=iNofhDA3OUk:_X3i9-0N2MU:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=iNofhDA3OUk:_X3i9-0N2MU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=iNofhDA3OUk:_X3i9-0N2MU:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/iNofhDA3OUk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:28:19.269+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/little-guide-to-perl-regular.html</feedburner:origLink></item><item><title>About foreach</title><link>http://feedproxy.google.com/~r/Techdiary/~3/LIoXwt5BHqk/about-foreach.html</link><category>about the foreach loop</category><category>Perl loop construct: foreach</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:58:47 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-3086351352141437307</guid><description>&lt;span style="font-family:verdana;"&gt;After a long time...&lt;br /&gt;This post is about the foreach loop construct. There is something special about the foreach loop, that I noticed recently. Consider this script:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my @array = (1,2,3,4,5,6,7,8,9,0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;foreach my $ele (@array) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;print "$ele\n";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Yes, this simply prints the array.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;The specialty of foreach is that it assigns the reference of each element to $ele. This is true even if you use an array reference in foreach. This means that if you modify an element inside foreach the array is affected.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;my @array = (1,2,3,4,5,6,7,8,9,0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;foreach my $ele (@array) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;print "$ele\n";&lt;br /&gt;$ele = '' if ($ele == 5);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Consider above script &amp;amp; then print all the array elements, you will notice 5 is gone.&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; &lt;/span&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;I have discussed with the &lt;a href="http://perlmonks.org/"&gt;perlmonks&lt;/a&gt;, visit this thread for more info: &lt;/span&gt;&lt;br /&gt;&lt;a href="http://perlmonks.org/?node_id=696953"&gt;&lt;span style="font-family:verdana;"&gt;http://perlmonks.org/?node_id=696953&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-3086351352141437307?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DKVquKDJUmXqfZ4lfG6ADCduHA8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DKVquKDJUmXqfZ4lfG6ADCduHA8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DKVquKDJUmXqfZ4lfG6ADCduHA8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DKVquKDJUmXqfZ4lfG6ADCduHA8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LIoXwt5BHqk:hfaCO8Y0Nko:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LIoXwt5BHqk:hfaCO8Y0Nko:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LIoXwt5BHqk:hfaCO8Y0Nko:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LIoXwt5BHqk:hfaCO8Y0Nko:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LIoXwt5BHqk:hfaCO8Y0Nko:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/LIoXwt5BHqk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:28:47.697+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/about-foreach.html</feedburner:origLink></item><item><title>Always confused with 2&gt;&amp;1</title><link>http://feedproxy.google.com/~r/Techdiary/~3/F7jIYwM4InI/always-confused-with-2.html</link><category>redirect stderr to stdout</category><category>linux redirection operators</category><category>redirection in Perl script</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 01:59:57 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-6094204668825055076</guid><description>&lt;span style="font-family:verdana;"&gt;For those confused, I am talking about the stdout &amp;amp; stderr. And redirection operators.&lt;br /&gt;&lt;br /&gt;This is more of the commands used in linux terminals.&lt;br /&gt;&lt;br /&gt;Consider this command:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;tar -cvf filename.tar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you run this command it prints a lot on stdout (terminal). So if you want to redirect this output to /dev/null you would do that using:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;tar -cvf filename.tar 1&gt;/dev/null&lt;br /&gt;  (or better)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;tar -cvf filename.tar.gz &gt;/dev/null&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;If you are using tar in a script &amp;amp; want to capture/redirect the stdout of tar in a file, you can use:&lt;span style="font-style: italic;"&gt;&lt;br /&gt;tar -cvf filename.tar &gt;tar_stdout.log&lt;br /&gt;  (here &gt; symbol is used to redirect)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;Now, if there is an error while tarring (say disk full). Then the command will print error on stderr &amp;amp; will exit. So how will you capture the errors, now you want to redirect both stderr &amp;amp; stdout to files.&lt;br /&gt;&lt;br /&gt;There are to scenarios here:&lt;br /&gt;1. You want to redirect to two seperate files:&lt;br /&gt;          &lt;span style="font-style: italic;"&gt;tar -cvf filename.tar 1&gt;tar_stdout.log 2&gt;tar_stderr.log&lt;br /&gt;&lt;/span&gt;2. You want to redirect stdout &amp;amp; stderr to a single file:&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;tar -cvf filename.tar &gt;tar_stds.log 2&gt;&amp;amp;1&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Remember always: &lt;/span&gt;This applies to all commands:&lt;br /&gt;The arguments are put to a variable (&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;ARGV&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;) of that process, and this variable is accessed as a stack. In the previous example 2&gt;&amp;amp;1 (instruction to the shell to redirect 2 to 1) should be at the end. So that this (2&gt;&amp;amp;1) redirection is arranged first &amp;amp; then 1&gt;tar_stds.log. Good example is:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        mkdir dir1/dir2 dir1        --&gt; Valid&lt;br /&gt;      mkdir dir1 dir1/dir2        --&gt; Invalid&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Redirection operators include:&lt;br /&gt;&gt; (output redirect)&lt;br /&gt;&lt; (input redirect) &gt;&gt; (output redirect but append)&lt;br /&gt;&lt;br /&gt;The same redirect operators can be used to redirect I/O to other file numbers OR to files. The distinction is:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;tar -cvf file.tar 1&gt;stdout.log&lt;/span&gt;    -&gt; this acts as redirect to file&lt;br /&gt;&lt;span style="font-style: italic;"&gt;tar -cvf file.tar 1&gt;&amp;amp;2&lt;/span&gt;              -&gt; this acts as redirect to another file number(notice the &amp;amp;)&lt;br /&gt;&lt;br /&gt;PS:-&lt;br /&gt;I use bash&lt;br /&gt;&lt;span style="font-style: italic;"&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/3366815763976900792-6094204668825055076?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zxoQVgskXuqhUIAKOQOKSZg0leM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zxoQVgskXuqhUIAKOQOKSZg0leM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zxoQVgskXuqhUIAKOQOKSZg0leM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zxoQVgskXuqhUIAKOQOKSZg0leM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=F7jIYwM4InI:JxhZn-zmnhc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=F7jIYwM4InI:JxhZn-zmnhc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=F7jIYwM4InI:JxhZn-zmnhc:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=F7jIYwM4InI:JxhZn-zmnhc:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=F7jIYwM4InI:JxhZn-zmnhc:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/F7jIYwM4InI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:29:57.868+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/always-confused-with-2.html</feedburner:origLink></item><item><title>PERL References</title><link>http://feedproxy.google.com/~r/Techdiary/~3/LisHGkYh4H4/perl-references.html</link><category>Perl references</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:00:33 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-2952323454652028173</guid><description>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_NQ1Ssrf_DXw/SGsgGKnjpPI/AAAAAAAAAcI/WTjsuImzMxU/s1600-h/pointers.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_NQ1Ssrf_DXw/SGsgGKnjpPI/AAAAAAAAAcI/WTjsuImzMxU/s320/pointers.JPG" alt="" id="BLOGGER_PHOTO_ID_5218299883540423922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Familiar with C pointers?&lt;br /&gt;&lt;br /&gt;In C pointers are variables&lt;span style="font-family:verdana;"&gt; &lt;/span&gt;that contains the location of some other piece of data. That is, it can be a machine address.&lt;br /&gt;&lt;br /&gt;In similar lines PERL also supports pointer variables called &lt;span style="font-style: italic;"&gt;references&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;If you do not understand the pointer concept, here is an illustration (I had read this in a book on 8085, long back):&lt;br /&gt;Take a look at the picture above.&lt;br /&gt;&lt;br /&gt;The image is self explanatory, cup c1 analogous to a pointer variable has a piece of paper that has the name of another cup (&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;address&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;) that has the juice which is cup c2.&lt;br /&gt;&lt;br /&gt;Similarly, in PERL consider c1 is the reference to variable c2. These references can point to a scalar/array/hash/a subroutine.&lt;br /&gt;&lt;br /&gt;Syntax:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my $scalar_ref = \$scalar_a;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my $array_ref = \@array_a;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my $hash_ref = \%hash_a;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my $sub_ref = \&amp;amp;find_average;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here the slash (\) operator is used to create references. References can be anonymous too, that is without any name. Anonymous hashes can be used to create complex data structures such as array of hashes, hashes of hashes, etc&lt;br /&gt;&lt;br /&gt;Also references can be created to file handles &amp;amp; type globs.&lt;br /&gt;&lt;br /&gt;References are just like other scalar variables. Perl also offers a function ref() to check the type of reference a scalar holds. For example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;$ref_type = ref($scalar_ref);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;ref() returns (without double-quotes)&lt;br /&gt;"SCALAR" for scalar refs&lt;br /&gt;"ARRAY" for arrays&lt;br /&gt;"HASH" for hash&lt;br /&gt;"CODE" for subroutine&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;It returns undef for a scalar variable. For more info on this you can visit: &lt;a href="http://perldoc.perl.org/functions/ref.html"&gt;http://perldoc.perl.org/functions/ref.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And for more info on references, visit: &lt;a href="http://perldoc.perl.org/perlreftut.html"&gt;http://perldoc.perl.org/perlreftut.html&lt;/a&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/3366815763976900792-2952323454652028173?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aQIC7mni5_yhTwcoUD4T_Ou3Ilo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aQIC7mni5_yhTwcoUD4T_Ou3Ilo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aQIC7mni5_yhTwcoUD4T_Ou3Ilo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aQIC7mni5_yhTwcoUD4T_Ou3Ilo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LisHGkYh4H4:mkE18gWycCQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LisHGkYh4H4:mkE18gWycCQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LisHGkYh4H4:mkE18gWycCQ:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=LisHGkYh4H4:mkE18gWycCQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=LisHGkYh4H4:mkE18gWycCQ:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/LisHGkYh4H4" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:30:33.701+05:30</app:edited><media:thumbnail url="http://1.bp.blogspot.com/_NQ1Ssrf_DXw/SGsgGKnjpPI/AAAAAAAAAcI/WTjsuImzMxU/s72-c/pointers.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/perl-references.html</feedburner:origLink></item><item><title>About being 'strict' (use strict)</title><link>http://feedproxy.google.com/~r/Techdiary/~3/E5yvUDbKBQE/about-being-strict-use-strict.html</link><category>about being strict</category><category>about strict</category><category>Perl script using 'use strict'</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:01:13 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-7347281924201688733</guid><description>&lt;span style="font-family:verdana;"&gt;This post is about using the strict pragma.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I always use this pragma in my scripts. It helps you in keeping the script neat &amp;amp; clean.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;As you know that by default variables are created &amp;amp; destroyed lexically in PERL, what I mean is by default (if you do not mention "my", "our" or "local") all variables are lexically scoped. This leads actually to errors when you mis-spell the variable names in your script.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;For example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Consider this script, of adding two numbers:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;$variable1 = 10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;$variable2 = 20;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;$result = $variable1 + $variable2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This is a small script &amp;amp; may not have mistakes, but look at the bigger picture.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Suppose you made a mistake in the script, only just a typo:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;$variable1 = 10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; $variable2 = 20;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt; $result = $variable1 + $varaible2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The results are annoying. It seems like there is a logical bug (considering a bigger script), but no there is a typo. This can be caught, using the pragma strict.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Strict is pretty strict, you have to explicitly mentioned the scope of the variables when you declare them. The above script (the one with mistake) will now become:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;use strict;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;my $variable1 = 10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;my $variable2 = 20;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;my $result = $variable1 + $varaible2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Try running this script, you will get this error:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;"Global symbol "$varaible2" requires explicit package name at test_strict.pl line 4.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Execution of test_strict.pl aborted due to compilation errors."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I think you have noticed the error by now.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Using strict pragma affects the subroutines, references &amp;amp; variables. You can even turnoff strict on these, for example:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;no strict "vars";&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;For more details, goto: &lt;/span&gt;&lt;a href="http://perldoc.perl.org/strict.html"&gt;perldoc.perl.org/strict.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Bottom line :-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Always &lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;'use strict&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;' and '&lt;span style="font-style: italic;"&gt;no strict&lt;/span&gt;' whereever necessary.&lt;/span&gt;&lt;br /&gt;&lt;span class="a"&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-7347281924201688733?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Yih6fPVtyywjjqDSNxDDt8FW6Pw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yih6fPVtyywjjqDSNxDDt8FW6Pw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Yih6fPVtyywjjqDSNxDDt8FW6Pw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yih6fPVtyywjjqDSNxDDt8FW6Pw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=E5yvUDbKBQE:CdKdGmgm13Q:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=E5yvUDbKBQE:CdKdGmgm13Q:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=E5yvUDbKBQE:CdKdGmgm13Q:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=E5yvUDbKBQE:CdKdGmgm13Q:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=E5yvUDbKBQE:CdKdGmgm13Q:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/E5yvUDbKBQE" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:31:13.514+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/07/about-being-strict-use-strict.html</feedburner:origLink></item><item><title>This time its a Shell script</title><link>http://feedproxy.google.com/~r/Techdiary/~3/QPQLeOZso8I/this-time-its-shell-script.html</link><category>shell script to find directory size of all directories under pwd</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:02:03 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-433170644820812247</guid><description>This small shell  script is to find the sizes of each folder under pwd:&lt;br /&gt;&lt;br /&gt;This script will print folder names along with its size. The output is redirected to a &lt;span style="font-style: italic;"&gt;temp.txt&lt;/span&gt;, you can change the name of the file.&lt;br /&gt;&lt;br /&gt;Run this script in bash.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;find -type d -maxdepth 1 | while read dir; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      if [ $dir == "." ]; then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           continue;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;     else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;           du -sh $dir;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    fi;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;done &gt; temp.txt&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-433170644820812247?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KouApPJYcnrwp3VxHu_ik8ms8-E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KouApPJYcnrwp3VxHu_ik8ms8-E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KouApPJYcnrwp3VxHu_ik8ms8-E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KouApPJYcnrwp3VxHu_ik8ms8-E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=QPQLeOZso8I:9KXU_ie7KZ0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=QPQLeOZso8I:9KXU_ie7KZ0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=QPQLeOZso8I:9KXU_ie7KZ0:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=QPQLeOZso8I:9KXU_ie7KZ0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=QPQLeOZso8I:9KXU_ie7KZ0:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/QPQLeOZso8I" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:32:03.063+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/06/this-time-its-shell-script.html</feedburner:origLink></item><item><title>Find the host/computer name from its IP &amp; vice versa</title><link>http://feedproxy.google.com/~r/Techdiary/~3/R5OdHfstRAo/find-hostcomputer-name-from-its-ip-vice.html</link><category>find computer's IP using hostname</category><category>find computer ip using its name</category><category>how to find the host computer name</category><category>find hostname using computer's IP</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:05:22 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-1202759474244184802</guid><description>Here is a small snippet of PERL code to display a host/computer's name from its IP address.&lt;br /&gt;&lt;br /&gt;use Socket;&lt;br /&gt;$iaddr = inet_aton("206.190.60.37");&lt;br /&gt;$name  = gethostbyaddr($iaddr, AF_INET);&lt;br /&gt;print "$name\n";&lt;br /&gt;&lt;br /&gt;Running this code will give the host name as w2.rc.vip.re4.yahoo.com&lt;br /&gt;&lt;br /&gt;Similarly, you can get the IP address of a host/computer whose name is known.&lt;br /&gt;Below is the code for that:&lt;br /&gt;&lt;br /&gt;use Socket;&lt;br /&gt;$iaddr = gethostbyname("www.google.co.in");&lt;br /&gt;$addr = inet_ntoa($iaddr);&lt;br /&gt;print "$addr\n";&lt;br /&gt;&lt;br /&gt;P S -&lt;br /&gt;Your computer should be connected to the internet, to try these example.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-1202759474244184802?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4dyALOtPsrGiiGw8ZwVt5g2_17I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4dyALOtPsrGiiGw8ZwVt5g2_17I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4dyALOtPsrGiiGw8ZwVt5g2_17I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4dyALOtPsrGiiGw8ZwVt5g2_17I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=R5OdHfstRAo:yfCqvSfSmOk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=R5OdHfstRAo:yfCqvSfSmOk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=R5OdHfstRAo:yfCqvSfSmOk:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=R5OdHfstRAo:yfCqvSfSmOk:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=R5OdHfstRAo:yfCqvSfSmOk:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/R5OdHfstRAo" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:35:22.369+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/06/find-hostcomputer-name-from-its-ip-vice.html</feedburner:origLink></item><item><title>Accessing a file in PERL</title><link>http://feedproxy.google.com/~r/Techdiary/~3/tdimhCAM0bI/accessing-file-in-perl.html</link><category>file access in Perl</category><category>read file in Perl</category><category>write to file in Perl</category><author>vikas.nv@gmail.com (Viki)</author><pubDate>Mon, 11 Aug 2008 02:04:17 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3366815763976900792.post-821009064397744741</guid><description>This is simplified using open().&lt;br /&gt;&lt;br /&gt;Usage: &lt;span style="font-style: italic;"&gt;open(FILEHANDLE, accessMode_with_fileName)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FILEHANDLE&lt;/span&gt; is like a pointer to the file's contents.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;accessMode_with_fileName&lt;/span&gt; is actually composed of two i.e.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;1. &lt;span style="font-style: italic;"&gt;Access Mode&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;: that specifies how you wan to access the file. It can be&lt;br /&gt;     a. Read, where you can just read from the file&lt;br /&gt;     b. Write, where you can just write to the file&lt;br /&gt;     c. Append, where you can write to the end of the file&lt;br /&gt;What you use depends on the requirement. To specify one of these modes you need to use any of these symbols : &amp;lt; (read), &amp;gt; (write) &amp;amp; &amp;gt;&amp;gt; (append). If you open a file without any of these symbols, it will default to read mode.&lt;br /&gt;You can put a '+'  in front of the '&gt;'  or '&lt;'  to indicate that you want both read and write access to the file (I have not used that, pretty much).  &lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;2. &lt;span style="font-style: italic;"&gt;Filename&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;: The second component is the filename itself.  so if you want to open a file (say /home/vik/foo) for reading the open call looks like:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="font-style: italic;"&gt;open (FILE, "&amp;lt;/home/vik/foo");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;     &lt;span style="font-style: italic;"&gt;open (FILE, "/home/vik/foo"); ## NO Access mode symbol is by default read mode&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The same example holds good for all other modes, you have to just change the access mode symbol as per requirement.&lt;br /&gt;&lt;br /&gt;The return value of open() is undef if it cannot open the file, so this check can be put using 'or', like this:&lt;br /&gt;&lt;br /&gt;     &lt;span style="font-style: italic;"&gt;open (FILE, "&amp;lt;/home/vik/foo") or die "Could not open file for reading: $!\n";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here $! is a special variable that holds the error.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Reading/Writing using the file handle&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After opening the file for reading, you can access the files' contents using a scalar variable / an array. Here are the examples:&lt;br /&gt;1. &lt;span style="font-style: italic;"&gt;Using a scalar&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;: If you want to read a file line by line, use a scalar variable like this,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my $files_line = &amp;lt;FILE&amp;gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Remember this always,&lt;/span&gt; when you read a line from the file the '\n' (newline character) will be at the end of the read contents, so use chomp() to remove any newline characters.&lt;br /&gt;So the example becomes:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my $files_line = &amp;lt;FILE&amp;gt;;&lt;br /&gt;chomp $files_lines;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. &lt;span style="font-style: italic;"&gt;Using an array&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;If you want to read all the lines of a file, you use the array. See this example below:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my @files_contents = &amp;lt;FILE&amp;gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With the chomp:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;my @files_contents = &amp;lt;FILE&amp;gt;;&lt;br /&gt;chomp(@files_contents);&lt;/span&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Writing to a file&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Use print to write to a file. See this example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;print FILE "I want to be in a file\n"&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3366815763976900792-821009064397744741?l=techdiary-viki.blogspot.com'/&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/d26OXBSXw_2lQkPGIhi028b8hcg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d26OXBSXw_2lQkPGIhi028b8hcg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/d26OXBSXw_2lQkPGIhi028b8hcg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d26OXBSXw_2lQkPGIhi028b8hcg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tdimhCAM0bI:NcFHUwrCd6I:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tdimhCAM0bI:NcFHUwrCd6I:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tdimhCAM0bI:NcFHUwrCd6I:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:l6gmwiTKsz0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=l6gmwiTKsz0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?i=tdimhCAM0bI:NcFHUwrCd6I:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Techdiary?a=tdimhCAM0bI:NcFHUwrCd6I:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Techdiary?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Techdiary/~4/tdimhCAM0bI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T14:34:17.049+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://techdiary-viki.blogspot.com/2008/06/accessing-file-in-perl.html</feedburner:origLink></item><media:credit role="author">Viki</media:credit><media:rating>nonadult</media:rating><media:description type="plain">Perl: Tips &amp; Tutorials</media:description></channel></rss>
