<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6755173720995974466</atom:id><lastBuildDate>Thu, 26 Mar 2026 07:47:53 +0000</lastBuildDate><category>Top 10 Unix Interview Questions</category><category>Unix Interview Questions</category><category>Interview Questions</category><category>Perl Interview Questions</category><category>check for oracle privileges</category><category>15 Most Java Interview Questions for Experienced</category><category>How to analyze tables</category><category>How to create DB Link</category><category>Oracle Day to Day Commands</category><category>Oracle Production Support Tips</category><category>Oracle for Unix</category><category>Perl Frequently Asked Questions</category><category>Top 10 Perl Interview Questions</category><category>check your oracle version</category><category>10 Tricky Java Interview Questions</category><category>AWK</category><category>Dot NET Framework</category><category>Dot NET Interview Questions and Answers</category><category>Job Interview Questions</category><category>Oracle DBA Commands</category><category>Perl For Interview</category><category>Perl Scripting</category><category>Unix Oracle Connectivity</category><category>AWK Interview Questions</category><category>AWK One Liners</category><category>Awk One Liners for Unix Interviews</category><category>Awk Tricks</category><category>Interview Question&#39;s</category><category>Java Interview Questions: 10 Common Questions</category><category>Jobs in Hyderabad</category><category>Jobs in NCR</category><category>Jobs in Noida</category><category>Oracle Enable and Disable Constraints</category><category>Oracle For Application DBA</category><category>Oracle Production Support Commands</category><category>Perl</category><category>Perl Scripting Tips</category><category>SQLPLUS via Unix</category><category>Sed Command</category><category>Sybase</category><category>Sybase Top 10 Interview Questions</category><category>Unix</category><category>Unix  Script to connect to oracle</category><category>Unix AWK Command</category><category>Unix Commands</category><category>Unix Scripting</category><category>Unix Sed Command</category><category>Unix Symlink Creation</category><category>10 Core Java Interview Questions &amp; Answers for Senior Experienced Developer</category><category>Advanced use of sed command</category><category>Append Text to End in Unix File</category><category>Change Whitespaces to a Single Space in Unix</category><category>Civil Services</category><category>DBA Tips</category><category>Delete Empty Lines in UNIX</category><category>Difference between AWK and SED</category><category>Disable Warning in Perl</category><category>Engineering Interview Questions</category><category>Find Command</category><category>Govt Jobs</category><category>IAS</category><category>IPS</category><category>Java Interview Questions</category><category>Jobs In gurgaon</category><category>Jobs in Bangalore</category><category>Jobs in Chennai</category><category>Jobs in Delhi</category><category>Jobs in Pune</category><category>Joining two files parallely using awk:</category><category>Most Asked Unix Questions</category><category>Oracle Commands for Production Support</category><category>Perl Copy Files</category><category>Perl Move Files</category><category>Perl Tips</category><category>Prime Minister&#39;s Rural Development Fellows (PMRDF) Scheme</category><category>Print Even Lines in UNIX</category><category>Print Odd Lines in UNIX</category><category>Print The Ourput in HTML of SQL Query</category><category>Read a File Backwards in UNIX</category><category>SED</category><category>Sarkaari Naukari</category><category>Script for checking the file older than 10 minutes</category><category>Sed Interview Questions</category><category>Sed one Liners</category><category>Shell scripting interview questions and answers</category><category>Sql</category><category>State Services</category><category>Symlink In Unix</category><category>TK Prof</category><category>Table Count Script in Oracle via Unix</category><category>Top 10 Questions of Java Strings</category><category>Top 10 tricky Java interview questions and answers</category><category>Top 25 Unix interview questions with answers</category><category>Top Command In Unix</category><category>Unix AWK</category><category>Unix CleanUp Scripts</category><category>Unix Interview Questions and Commands</category><category>Unix Production Support Scripts</category><category>Unix ReadyMade Scripts</category><category>Unix SED</category><category>Unix Script</category><category>Unix Sed Questions</category><category>Unix Sed Trics</category><category>Unix Top 10 Files</category><category>Unix Tricks</category><category>Unix Utilities</category><category>Unix bad interpreter issue</category><category>insert a blank line above every line which matches &quot;regex&quot;</category><category>lsof In Unix</category><category>make utility in unix</category><category>print the last field of each line in Unix</category><category>sort a delimited file on the basis of a column</category><category>switch the first 2 fields of every line in Unix</category><category>useful tricks of sed command</category><title>HelpYourSelfInOffice</title><description></description><link>http://asuddenhelp.blogspot.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-7497444507423352790</guid><pubDate>Sat, 10 May 2014 12:55:00 +0000</pubDate><atom:updated>2014-05-10T05:55:44.928-07:00</atom:updated><title>AWR automation</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
#!/bin/ksh&lt;br /&gt;
set -x&lt;br /&gt;
export RECIPENTS=abc@xyz.com&lt;br /&gt;
export DT1=`date +%d%m_%H%M`&lt;br /&gt;
export PATH=$PATH:/usr/bin:/usr/local/bin&lt;br /&gt;
&lt;br /&gt;
cd /opt/prod/support/genawr/awr&lt;br /&gt;
rm *.zip *.html&lt;br /&gt;
&lt;br /&gt;
#######################################################&lt;br /&gt;
# FORMAT TO TUN THE SCRIPT&lt;br /&gt;
# script_name connect_string duration instance_number&lt;br /&gt;
######################################################&lt;br /&gt;
/opt/prod/support/genawr/generate_awr.sh username/passwd@dbname 6 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cd /opt/prod/support/genawr/awr&lt;br /&gt;
&lt;br /&gt;
zip awr_prod_$DT1.zip *.html&lt;br /&gt;
&lt;br /&gt;
uuencode awr_prod_$DT1.zip awr_prod_$DT1.zip | mailx -s &quot;AWR Report for all Production databases for last 6 hrs &quot; -m $RECIPENTS&lt;br /&gt;
&lt;br /&gt;
$ cat /opt/prod/support/genawr/generate_awr.sh&lt;br /&gt;
#!/bin/ksh&lt;br /&gt;
set -x&lt;br /&gt;
export ORACLE_HOME=/opt/oracle/product/10.2.0&lt;br /&gt;
export PATH=$PATH:$ORACLE_HOME/bin&lt;br /&gt;
export HOMEDIR=/opt/prod/support/genawr/&lt;br /&gt;
export RECIPENTS=mark@abc.com&lt;br /&gt;
dbname=`echo $1 | cut -d&#39;@&#39; -f2`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if [[ $# -lt 1 ]];then&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;Please Enter valid parameter to this script as follows:&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;\ngenerate_awr.sh &amp;lt;DB_USER&amp;gt;/DB_PASSWD@CONN_STRING&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit;&lt;br /&gt;
else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;Connecting to $1&quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
sqlplus -s ${1} &amp;lt;&amp;lt; EOF &amp;gt; $HOMEDIR/generate_awr.log&lt;br /&gt;
set head off&lt;br /&gt;
set pages 0&lt;br /&gt;
set lines 132&lt;br /&gt;
set echo off&lt;br /&gt;
set feedback off&lt;br /&gt;
spool $HOMEDIR/snapid.txt&lt;br /&gt;
--select distinct trim(snap_id) from dba_hist_snapshot where to_number(to_char(end_interval_time,&#39;yyyymmddHH&#39;)) = to_number(to_char(sysdate,&#39;yyyymmddHH&#39;));&lt;br /&gt;
select snap_id from dba_hist_snapshot where to_number(to_char(end_interval_time,&#39;yyyymmddHH&#39;)) = to_number(to_char(sysdate,&#39;yyyymmddHH&#39;)) order by end_interval_time desc;&lt;br /&gt;
spool off;&lt;br /&gt;
&lt;br /&gt;
spool $HOMEDIR/dbid.txt&lt;br /&gt;
&lt;br /&gt;
select distinct trim(dbid) from dba_hist_snapshot;&lt;br /&gt;
&lt;br /&gt;
spool off;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
sed &#39;s/ //g&#39; $HOMEDIR/snapid.txt &amp;gt; $HOMEDIR/temp.txt ; &amp;nbsp;mv $HOMEDIR/temp.txt $HOMEDIR/snapid.txt&lt;br /&gt;
sed &#39;s/ //g&#39; $HOMEDIR/dbid.txt &amp;gt; $HOMEDIR/temp1.txt ; &amp;nbsp;mv $HOMEDIR/temp1.txt $HOMEDIR/dbid.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
l_end=`cat $HOMEDIR/snapid.txt | head -1`&lt;br /&gt;
echo &quot;l_begin=`expr ${l_end} - ${2}`&quot;&lt;br /&gt;
l_begin=`expr ${l_end} - ${2}`&lt;br /&gt;
l_dbid=`cat $HOMEDIR/dbid.txt`&lt;br /&gt;
&lt;br /&gt;
#rm $HOMEDIR/*.html&lt;br /&gt;
&lt;br /&gt;
sqlplus -s $1 &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; $HOMEDIR/generate_awr.log&lt;br /&gt;
set head off&lt;br /&gt;
set pages 0&lt;br /&gt;
set lines 500&lt;br /&gt;
set echo off&lt;br /&gt;
set feedback off&lt;br /&gt;
spool $HOMEDIR/awr.txt&lt;br /&gt;
&lt;br /&gt;
SELECT output FROM TABLE (dbms_workload_repository.awr_report_html($l_dbid,$3,$l_begin,$l_end));&lt;br /&gt;
&lt;br /&gt;
spool off;&lt;br /&gt;
&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
mv $HOMEDIR/awr.txt $HOMEDIR/awr/awr_$dbname.html&lt;br /&gt;
&lt;br /&gt;
#cd $HOMEDIR&lt;br /&gt;
&lt;br /&gt;
#zip awr_${l_begin}_${l_end}.zip awr_${l_begin}_${l_end}.html&lt;br /&gt;
&lt;br /&gt;
#uuencode awr_${l_begin}_${l_end}.zip awr_${l_begin}_${l_end}.zip | mailx -s &quot;AWR Report for last 6 hours&quot; -m $RECIPENTS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2014/05/awr-automation.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-5460207370595948652</guid><pubDate>Sun, 01 Dec 2013 06:57:00 +0000</pubDate><atom:updated>2013-11-30T22:57:15.529-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">make utility in unix</category><category domain="http://www.blogger.com/atom/ns#">Symlink In Unix</category><category domain="http://www.blogger.com/atom/ns#">Top Command In Unix</category><category domain="http://www.blogger.com/atom/ns#">Unix Symlink Creation</category><title>Unix Job Interview Questions  </title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Adding 30 days to current date using PERL inside SHELL&lt;br /&gt;
&lt;br /&gt;
#! /usr/bin/ksh&lt;br /&gt;
&lt;br /&gt;
dt1=`perl -l -e &#39;$date=(localtime(time + (30 * 24 * 60 *60))); print $date;&#39;`&lt;br /&gt;
&lt;br /&gt;
dt=`echo $dt1|awk &#39;{if($3&amp;lt;10) print $1&quot; &quot;$2&quot; 0&quot;$3&quot; &quot;$4&quot; &quot;$5;else print $0}&#39;`&lt;br /&gt;
&lt;br /&gt;
echo $dt|awk &#39;{print $5&quot;-&quot;$2&quot;-&quot;$3&quot;23:59:59&quot;}&#39;|sed -e &#39;s/Jan/01/g&#39;\;&#39;s/Feb/02/g&#39;\;&#39;s/Mar/03/g&#39;\;&#39;s/Apr/04/g&#39;\;&#39;s/May/05/g&#39;\;&#39;s/Jun/06/g&#39;\;&#39;s/Jul/07/g&#39;\;&#39;s/Aug/08/g&#39;\;&#39;s/Sep/09/g&#39;\;&#39;s/Oct/10/g&#39;\;&#39;s/Nov/11/g&#39;\;&#39;s/Dec/12/g&#39;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Print 3 lines before pattern match using sed and awk ..&lt;br /&gt;
&lt;br /&gt;
Q: How do you display your running kernel version? (Solaris, AIX, Linux)&lt;br /&gt;
A: Linux # uname –r , Solaris # showrev&lt;br /&gt;
&lt;br /&gt;
Q: Which command do you use to display a table of running processes? (Solaris, AIX, Linux)&lt;br /&gt;
A: Linux # ps –ef and top , Solaris # prstat&lt;br /&gt;
&lt;br /&gt;
Q: Which file do you modify to configure a domain name resolver? (Solaris, AIX, Linux)&lt;br /&gt;
A: Linux # /etc/resolv.conf , Solaris # /etc/resolv.conf&lt;br /&gt;
&lt;br /&gt;
Q: Which file contains a list of locally defined hostnames and corresponding IP addresses? (Solaris, AIX, Linux)&lt;br /&gt;
A: Linux # /etc/hosts , Solaris # /etc/hosts and linked file /etc/inet/hosts&lt;br /&gt;
&lt;br /&gt;
Q: How do you display a routing table? (Solaris, AIX, Linux)&lt;br /&gt;
A: Linux # ip route show or #netstat –nr or #route –n and Solaris # netstat –nr and #route -n&lt;br /&gt;
&lt;br /&gt;
Q: Which command would you use to view partitions and their sizes on Solaris?&lt;br /&gt;
A: # df -kh&lt;br /&gt;
&lt;br /&gt;
Q: Which OpenBoot command would you use to print/view OpenBoot environment variables on a SUN server?&lt;br /&gt;
A: #printenv&lt;br /&gt;
&lt;br /&gt;
Q: What does &quot;ypwhich&quot; command do? (Solaris, AIX, Linux)&lt;br /&gt;
A: # Will display NIS server to which client is connected to and which NIS Server is master for particular map specified with this command&lt;br /&gt;
&lt;br /&gt;
Q: which command would you use to create an OS user on Solaris and Linux?&lt;br /&gt;
A: Linux # useradd and Solaris #useradd&lt;br /&gt;
&lt;br /&gt;
Q: Which file contains passwords for local users on Solaris, Linux and on AIX?&lt;br /&gt;
A: Linux #/etc/shadow and Solaris # /etc/shadow&lt;br /&gt;
&lt;br /&gt;
Q: Which command would you use to list partitions on Linux?&lt;br /&gt;
A: Linux # mount –l or # df -kh&lt;br /&gt;
&lt;br /&gt;
Q: Which command/commands would you use to manage installed packages on RedHat Linux?&lt;br /&gt;
A: Linux # rpm&lt;br /&gt;
&lt;br /&gt;
Q: What is the default port for SSH server?&lt;br /&gt;
A: 22&lt;br /&gt;
&lt;br /&gt;
Q: Which command/commands would you use to manage installed packages on Solaris?&lt;br /&gt;
A: #pkginfo #pkgrm # pkgadd #pkgchk&lt;br /&gt;
&lt;br /&gt;
Q: What command would you use to install an OS patch on Solaris?&lt;br /&gt;
A: #showrev –p and #patchadd -p&lt;br /&gt;
&lt;br /&gt;
Q: Which Veritas command would you use to display a list of Veritas volumes?&lt;br /&gt;
A: # vxprint&lt;br /&gt;
&lt;br /&gt;
Q: Which Veritas command would you use to display a list of disks on a system?&lt;br /&gt;
A: # vxdx list&lt;br /&gt;
&lt;br /&gt;
Q: What is the main system configuration utility in AIX?&lt;br /&gt;
A:&lt;br /&gt;
&lt;br /&gt;
Q: Which file has a list of filesystems to be mounted at boot time on Solaris, Linux and AIX?&lt;br /&gt;
A: Linux # /etc/fstab and Solaris #/etc/vfstab&lt;br /&gt;
&lt;br /&gt;
Q. How to change all .my files to .txt in current directory??&lt;br /&gt;
Solution: for i in `ls *.my` ; do NEW=`echo $ised -e &#39;s/.my/.txt/g&#39;` ; mv $i $NEW ; done&lt;br /&gt;
&lt;br /&gt;
Q. How to change all .extn files to .my in entire directory recursively??&lt;br /&gt;
Solution:&lt;br /&gt;
find ./ -type f grep &quot;.extn$&quot; &amp;gt;files.txt;for i in `cat files.txt`;do NEW=`echo $ised &#39;s/.extn/.my/g&#39;`;mv &quot;${i}&quot; &quot;${NEW}&quot;;done;rm -f files.txt&lt;br /&gt;
&lt;br /&gt;
Q: What is umask??&lt;br /&gt;
Answer: umask is used to set default permission level in entire unix system. It can be set in .kshrc/.bashrc/.cshrc or init (So that to load at the time of login into shell)&lt;br /&gt;
&lt;br /&gt;
Q. What is inode??&lt;br /&gt;
Answer : inode represents any file/directory residing in your unix system with a numner known as inode number. It is unique for every file/dir. It is basically a reference that kernel use for any work related to that entity. &quot;ls -i filename&quot; will give you the inode number of that particu;ar file.&lt;br /&gt;
&lt;br /&gt;
Q. Explain general commands like ps,df, export, env, ufsdump, tar, cron, system.&lt;br /&gt;
Answer: EASY ONE&lt;br /&gt;
&lt;br /&gt;
Q. Explain the make utility in unix?? what are the parameters of a makefile and how to use them. What are macros in makefile.&lt;br /&gt;
Answer: Unix make utility is used to build a software package. It requires a makefile where all the bunch of the scripts/codes/programs are declared/defined. The main parameters of the make file are variable declaration, Macro declaration, Phony Target declaration and Clean-up block. Macros in a makefile represents the order in which the scripts would get executed.&lt;br /&gt;
&lt;br /&gt;
Q. What are the benefits of makefile over shell script??&lt;br /&gt;
Answer: Using makefile one can run the different scripts or programs or codes in one go. This can also be done by making a wrapper shell script which can execute the different scripts in one go. But then it would not be termed as a package because when we say a package it means that we have one installer (.exe) which can execute the bunch more efficiently and also this .exe will be in encrypted format. So in order to maintain efficiency and security makefile is given precedence over wrapper shell scripts.&lt;br /&gt;
&lt;br /&gt;
Q. What are hard links in UNIX??&lt;br /&gt;
Answer: A hard link is a reference to a file or directory that appears just like a file or directory, not a link. Hard links only work within a filesystem. In other words, don&#39;t use hard links between mounted filesystems. A hard link is only a reference to the original file, not a copy of the file. If the original file is deleted, the information will be lost.&lt;br /&gt;
To create a hard link of the file /export/home/fred/stuff to /var/tmp/thing, use:&lt;br /&gt;
&lt;br /&gt;
ln /export/home/fred/stuff /var/tmp/thing&lt;br /&gt;
&lt;br /&gt;
The syntax for creating a hard link of a directory is the same. To create a hard link of /var/www/html to /var/www/webroot, use:&lt;br /&gt;
&lt;br /&gt;
ln /var/www/html /var/www/webroot&lt;br /&gt;
&lt;br /&gt;
Q. What are the soft/symbolic links in unix ??&lt;br /&gt;
Answer: A symbolic link is a pointer to another file or directory. It can be used just like the original file or directory. A symbolic link appears in a long listing (ls -l) with a reference to the original file/directory. A symbolic link, as opposed to a hard link, is required when linking from one filesystem to another and can be used within a filesystem as well.&lt;br /&gt;
To create a symbolic link, the syntax of the command is similar to a copy or move command: existing file first, destination file second. For example, to link the directory /export/space/common/archive to /archive for easy access, use:&lt;br /&gt;
&lt;br /&gt;
ln -s /export/space/common/archive /archive&lt;br /&gt;
&lt;br /&gt;
To link the runtime control script /etc/init.d/httpd to /etc/rc2.d/S77httpd, use:&lt;br /&gt;
&lt;br /&gt;
cd /etc/rc2.d&lt;br /&gt;
ln -s ../init.d/httpd S77httpd&lt;br /&gt;
&lt;br /&gt;
Q. What is a command to kill the last background job??&lt;br /&gt;
Answer: kill $!&lt;br /&gt;
&lt;br /&gt;
Q. Bring a job to foreground by specifying its job number after the percent sign.&lt;br /&gt;
Answer: fg %jobnumber&lt;br /&gt;
(Note: jobnumber can be obtained by using jobs -l command)&lt;br /&gt;
&lt;br /&gt;
Q. Explain top command.&lt;br /&gt;
Answer: top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can sort the tasks by CPU usage, memory usage and runtime. can be better configured than the standard top from the procps suite. Most features can either be selected by an interactive command or by specifying the feature in the personal or system-wide configuration file.&lt;br /&gt;
&lt;br /&gt;
Q. Write a script which give you those records which are having CPU utilization more than 80%.&lt;br /&gt;
Answer: df -k awk &#39;NR==1{print $1&quot;\t&quot;$5&quot;\t&quot;$6}sub(&quot;%&quot;,&quot;&quot;,$5){if($5 &amp;gt;= 80) print $1&quot;\t&quot;$5&quot;%\t&quot;$NF}&#39;&lt;br /&gt;
&lt;br /&gt;
Q. How to pass arguments in an awk script??Answer: Using, cat a.txtawk -v awk_var=&quot;$shell_var&quot; &#39;{print $1 &quot;\t&quot; awk_var}&#39;&lt;br /&gt;
e.g. #! /usr/bin/sh&lt;br /&gt;
var=$*&lt;br /&gt;
cat ussd.txt &amp;gt;offpeak_input.txt&lt;br /&gt;
cat offpeaknawk -v var1=&quot;$var&quot; &#39;{print &quot;\&quot;1-&quot;$1&quot;\&quot;&quot;&quot;&quot;&quot;\&quot;&quot;$2&quot;\&quot;&quot;&quot;&quot;&quot;1006&quot;&quot;&quot;&quot;&quot;$3&quot;&quot;&quot;0&quot;&quot;&quot;&quot;-1&quot;&quot;&quot;&quot;-1&quot;&quot;&quot;&quot;\&quot;&quot;var1&quot; .Account balance is Rs..Bonus minutes.\&quot;&quot;}&#39;&amp;gt;&amp;gt;offpeak_input.txt&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/unix-job-interview-questions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-2501736161426210342</guid><pubDate>Sun, 01 Dec 2013 06:54:00 +0000</pubDate><atom:updated>2013-11-30T22:54:56.613-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AWK</category><category domain="http://www.blogger.com/atom/ns#">AWK Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">AWK One Liners</category><category domain="http://www.blogger.com/atom/ns#">Awk One Liners for Unix Interviews</category><category domain="http://www.blogger.com/atom/ns#">Awk Tricks</category><category domain="http://www.blogger.com/atom/ns#">print the last field of each line in Unix</category><category domain="http://www.blogger.com/atom/ns#">switch the first 2 fields of every line in Unix</category><title>Useful awk oneliners</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
FILE SPACING:&lt;br /&gt;
# double space a file&lt;br /&gt;
awk &#39;1;{print &quot;&quot;}&#39; awk &#39;BEGIN{ORS=&quot;\n\n&quot;};1&#39;&lt;br /&gt;
&lt;br /&gt;
# double space a file which already has blank lines in it. Output file should contain no more than one blank line between lines of text. NOTE: On Unix systems, DOS lines which have only CRLF (\r\n) are # often treated as non-blank, and thus &#39;NF&#39; alone will return TRUE.&lt;br /&gt;
awk &#39;NF{print $0 &quot;\n&quot;}&#39;&lt;br /&gt;
# triple space a file&lt;br /&gt;
awk &#39;1;{print &quot;\n&quot;}&#39;&lt;br /&gt;
NUMBERING AND CALCULATIONS:&lt;br /&gt;
# precede each line by its line number FOR THAT FILE (left alignment). Using a tab (\t) instead of space will preserve margins.&lt;br /&gt;
awk &#39;{print FNR &quot;\t&quot; $0}&#39; files*&lt;br /&gt;
&lt;br /&gt;
# precede each line by its line number FOR ALL FILES TOGETHER, with tab.&lt;br /&gt;
awk &#39;{print NR &quot;\t&quot; $0}&#39; files*&lt;br /&gt;
# number each line of a file (number on left, right-aligned) # Double the percent signs if typing from the DOS command prompt.&lt;br /&gt;
awk &#39;{printf(&quot;%5d : %s\n&quot;, NR,$0)}&#39;&lt;br /&gt;
# number each line of file, but only print numbers if line is not blank Remember caveats about Unix treatment of \r (mentioned above)&lt;br /&gt;
awk &#39;NF{$0=++a &quot; :&quot; $0};{print}&#39; awk &#39;{print (NF? ++a &quot; :&quot; :&quot;&quot;) $0}&#39;&lt;br /&gt;
# count lines (emulates &quot;wc -l&quot;)&lt;br /&gt;
awk &#39;END{print NR}&#39;&lt;br /&gt;
&lt;br /&gt;
# print the sums of the fields of every line&lt;br /&gt;
awk &#39;{s=0; for (i=1; i&amp;lt;=NF; i++) s=s+$i; print s}&#39;&lt;br /&gt;
# add all fields in all lines and print the sum&lt;br /&gt;
awk &#39;{for (i=1; i&amp;lt;=NF; i++) s=s+$i}; END{print s}&#39; # print every line after replacing each field with its absolute value awk &#39;{for (i=1; i&amp;lt;=NF; i++) if ($i &amp;lt; i =&quot; -$i;&quot; i=&quot;1;&quot; i =&quot; ($i&quot;&amp;gt;&lt;br /&gt;
# print the total number of fields (&quot;words&quot;) in all lines&lt;br /&gt;
awk &#39;{ total = total + NF }; END {print total}&#39; file&lt;br /&gt;
&lt;br /&gt;
# print the total number of lines that contain &quot;Beth&quot;&lt;br /&gt;
awk &#39;/Beth/{n++}; END {print n+0}&#39; file&lt;br /&gt;
# print the largest first field and the line that contains it Intended for finding the longest string in field 1&lt;br /&gt;
awk &#39;$1 &amp;gt; max {max=$1; maxline=$0}; END{ print max, maxline}&#39;&lt;br /&gt;
&lt;br /&gt;
# print the number of fields in each line, followed by the line&lt;br /&gt;
awk &#39;{ print NF &quot;:&quot; $0 } &#39;&lt;br /&gt;
&lt;br /&gt;
# print the last field of each line&lt;br /&gt;
awk &#39;{ print $NF }&#39;&lt;br /&gt;
&lt;br /&gt;
# print the last field of the last line&lt;br /&gt;
awk &#39;{ field = $NF }; END{ print field }&#39;&lt;br /&gt;
&lt;br /&gt;
# print every line with more than 4 fields&lt;br /&gt;
awk &#39;NF &amp;gt; 4&#39;&lt;br /&gt;
&lt;br /&gt;
# print every line where the value of the last field is &amp;gt; 4&lt;br /&gt;
awk &#39;$NF &amp;gt; 4&#39;&lt;br /&gt;
&lt;br /&gt;
TEXT CONVERSION AND SUBSTITUTION:&lt;br /&gt;
# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format&lt;br /&gt;
awk &#39;{sub(/\r$/,&quot;&quot;);print}&#39; # assumes EACH line ends with Ctrl-M&lt;br /&gt;
&lt;br /&gt;
# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format&lt;br /&gt;
awk &#39;{sub(/$/,&quot;\r&quot;);print}&lt;br /&gt;
&lt;br /&gt;
# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format&lt;br /&gt;
awk 1&lt;br /&gt;
&lt;br /&gt;
# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format # Cannot be done with DOS versions of awk, other than gawk:&lt;br /&gt;
gawk -v BINMODE=&quot;w&quot; &#39;1&#39; infile &amp;gt;outfile&lt;br /&gt;
&lt;br /&gt;
# Use &quot;tr&quot; instead.&lt;br /&gt;
tr -d \r outfile # GNU tr version 1.22 or higher&lt;br /&gt;
&lt;br /&gt;
# delete leading whitespace (spaces, tabs) from front of each line # aligns all text flush left&lt;br /&gt;
awk &#39;{sub(/^[ \t]+/, &quot;&quot;); print}&#39;&lt;br /&gt;
&lt;br /&gt;
# delete trailing whitespace (spaces, tabs) from end of each line&lt;br /&gt;
awk &#39;{sub(/[ \t]+$/, &quot;&quot;);print}&#39;&lt;br /&gt;
&lt;br /&gt;
# delete BOTH leading and trailing whitespace from each line&lt;br /&gt;
awk &#39;{gsub(/^[ \t]+[ \t]+$/,&quot;&quot;);print}&#39; awk &#39;{$1=$1;print}&#39; # also removes extra space&lt;br /&gt;
&lt;br /&gt;
# insert 5 blank spaces at beginning of each line (make page offset)&lt;br /&gt;
awk &#39;{sub(/^/, &quot; &quot;);print}&#39;&lt;br /&gt;
&lt;br /&gt;
# align all text flush right on a 79-column width&lt;br /&gt;
awk &#39;{printf &quot;%79s\n&quot;, $0}&#39; file*&lt;br /&gt;
&lt;br /&gt;
# center all text on a 79-character width&lt;br /&gt;
awk &#39;{l=length();s=int((79-l)/2); printf &quot;%&quot;(s+l)&quot;s\n&quot;,$0}&#39; file*&lt;br /&gt;
&lt;br /&gt;
# substitute (find and replace) &quot;foo&quot; with &quot;bar&quot; on each line&lt;br /&gt;
awk &#39;{sub(/foo/,&quot;bar&quot;);print}&#39; # replaces only 1st instance&lt;br /&gt;
gawk &#39;{$0=gensub(/foo/,&quot;bar&quot;,4);print}&#39; # replaces only 4th instance&lt;br /&gt;
awk &#39;{gsub(/foo/,&quot;bar&quot;);print}&#39; # replaces ALL instances in a line&lt;br /&gt;
# substitute &quot;foo&quot; with &quot;bar&quot; ONLY for lines which contain &quot;baz&quot;&lt;br /&gt;
awk &#39;/baz/{gsub(/foo/, &quot;bar&quot;)};{print}&#39;&lt;br /&gt;
# substitute &quot;foo&quot; with &quot;bar&quot; EXCEPT for lines which contain &quot;baz&quot; awk &#39;!/baz/{gsub(/foo/, &quot;bar&quot;)};{print}&#39;&lt;br /&gt;
# change &quot;scarlet&quot; or &quot;ruby&quot; or &quot;puce&quot; to &quot;red&quot;&lt;br /&gt;
awk &#39;{gsub(/scarletrubypuce/, &quot;red&quot;); print}&#39;&lt;br /&gt;
# reverse order of lines (emulates &quot;tac&quot;)&lt;br /&gt;
awk &#39;{a[i++]=$0} END {for (j=i-1; j&amp;gt;=0;) print a[j--] }&#39; file*&lt;br /&gt;
# if a line ends with a backslash, append the next line to it (fails if there are multiple lines ending with backslash...)&lt;br /&gt;
awk &#39;/\\$/ {sub(/\\$/,&quot;&quot;); getline t; print $0 t; next}; 1&#39; file*&lt;br /&gt;
# print and sort the login names of all users&lt;br /&gt;
awk -F &quot;:&quot; &#39;{ print $1 &quot;sort&quot; }&#39; /etc/passwd&lt;br /&gt;
# print the first 2 fields, in opposite order, of every line&lt;br /&gt;
awk &#39;{print $2, $1}&#39; file&lt;br /&gt;
# switch the first 2 fields of every line&lt;br /&gt;
awk &#39;{temp = $1; $1 = $2; $2 = temp}&#39; file&lt;br /&gt;
# print every line, deleting the second field of that line&lt;br /&gt;
awk &#39;{ $2 = &quot;&quot;; print }&#39;&lt;br /&gt;
# print in reverse order the fields of every line&lt;br /&gt;
awk &#39;{for (i=NF; i&amp;gt;0; i--) printf(&quot;%s &quot;,i);printf (&quot;\n&quot;)}&#39; file&lt;br /&gt;
# remove duplicate, consecutive lines (emulates &quot;uniq&quot;)&lt;br /&gt;
awk &#39;a !~ $0; {a=$0}&#39;&lt;br /&gt;
# remove duplicate, nonconsecutive lines&lt;br /&gt;
awk &#39;! a[$0]++&#39; # most concise script&lt;br /&gt;
awk &#39;!($0 in a) {a[$0];print}&#39; # most efficient script&lt;br /&gt;
# concatenate every 5 lines of input, using a comma separator between fields&lt;br /&gt;
awk &#39;ORS=%NR%5?&quot;,&quot;:&quot;\n&quot;&#39; file&lt;br /&gt;
&lt;br /&gt;
SELECTIVE PRINTING OF CERTAIN LINES:&lt;br /&gt;
# print first 10 lines of file (emulates behavior of &quot;head&quot;)&lt;br /&gt;
awk &#39;NR &amp;lt;&amp;gt;1{exit};1&#39;&lt;br /&gt;
# print the last 2 lines of a file (emulates &quot;tail -2&quot;)&lt;br /&gt;
awk &#39;{y=x &quot;\n&quot; $0; x=$0};END{print y}&#39;&lt;br /&gt;
# print the last line of a file (emulates &quot;tail -1&quot;)&lt;br /&gt;
awk &#39;END{print}&#39;&lt;br /&gt;
# print only lines which match regular expression (emulates &quot;grep&quot;)&lt;br /&gt;
awk &#39;/regex/&#39;&lt;br /&gt;
# print only lines which do NOT match regex (emulates &quot;grep -v&quot;)&lt;br /&gt;
awk &#39;!/regex/&#39;&lt;br /&gt;
# print the line immediately before a regex, but not the line # containing the regex&lt;br /&gt;
awk &#39;/regex/{print x};{x=$0}&#39; awk &#39;/regex/{print (x==&quot;&quot; ? &quot;match on line 1&quot; : x)};{x=$0}&#39;&lt;br /&gt;
# print the line immediately after a regex, but not the line containing the regex&lt;br /&gt;
awk &#39;/regex/{getline;print}&#39;&lt;br /&gt;
# grep for AAA and BBB and CCC (in any order)&lt;br /&gt;
awk &#39;/AAA/; /BBB/; /CCC/&#39;&lt;br /&gt;
# grep for AAA and BBB and CCC (in that order)&lt;br /&gt;
awk &#39;/AAA.*BBB.*CCC/&#39;&lt;br /&gt;
# print only lines of 65 characters or longer&lt;br /&gt;
awk &#39;length &amp;gt; 64&#39;&lt;br /&gt;
# print only lines of less than 65 characters&lt;br /&gt;
awk &#39;length &amp;lt; nr=&quot;=&quot;8,NR=&quot;=&quot;12&#39;&quot; nr=&quot;=&quot;52&#39;&quot; nr=&quot;=&quot;52&quot;&amp;gt;&lt;br /&gt;
CREDITS AND THANKS:http://student.northpark.edu/pemente/awk/awk1line.txt&lt;br /&gt;
&lt;br /&gt;
At below link the famous awk one liners by Eric Pement is explained.&lt;br /&gt;
http://www.catonmat.net/blog/awk-one-liners-explained-part-one/&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/useful-awk-oneliners.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-2246034110679829316</guid><pubDate>Sun, 01 Dec 2013 06:53:00 +0000</pubDate><atom:updated>2013-11-30T22:53:15.274-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Sed Command</category><category domain="http://www.blogger.com/atom/ns#">Sed Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Sed one Liners</category><category domain="http://www.blogger.com/atom/ns#">Unix SED</category><category domain="http://www.blogger.com/atom/ns#">Unix Sed Command</category><category domain="http://www.blogger.com/atom/ns#">Unix Sed Questions</category><category domain="http://www.blogger.com/atom/ns#">Unix Sed Trics</category><title>Useful sed one liners</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
FILE SPACING:&lt;br /&gt;
# double space a file&lt;br /&gt;
sed G&lt;br /&gt;
# double space a file which already has blank lines in it. Output file should contain no more than one blank line between lines of text.&lt;br /&gt;
sed &#39;/^$/d;G&#39;&lt;br /&gt;
# triple space a file&lt;br /&gt;
sed &#39;G;G&#39;&lt;br /&gt;
# undo double-spacing (assumes even-numbered lines are always blank)&lt;br /&gt;
sed &#39;n;d&#39;&lt;br /&gt;
# insert a blank line above every line which matches &quot;regex&quot;&lt;br /&gt;
sed &#39;/regex/{x;p;x;}&#39;&lt;br /&gt;
# insert a blank line below every line which matches &quot;regex&quot;&lt;br /&gt;
sed &#39;/regex/G&#39;&lt;br /&gt;
# insert a blank line above and below every line which matches &quot;regex&quot;&lt;br /&gt;
sed &#39;/regex/{x;p;x;G;}&#39;&lt;br /&gt;
NUMBERING:&lt;br /&gt;
# number each line of a file (simple left alignment). Using a tab (see # note on &#39;\t&#39; at end of file) instead of space will preserve margins.&lt;br /&gt;
sed = filename sed &#39;N;s/\n/\t/&#39;&lt;br /&gt;
# number each line of a file (number on left, right-aligned)&lt;br /&gt;
sed = filename sed &#39;N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /&#39;&lt;br /&gt;
# number each line of file, but only print numbers if line is not blank&lt;br /&gt;
sed &#39;/./=&#39; filename sed &#39;/./N; s/\n/ /&#39;&lt;br /&gt;
# count lines (emulates &quot;wc -l&quot;)&lt;br /&gt;
sed -n &#39;$=&#39;&lt;br /&gt;
&lt;br /&gt;
TEXT CONVERSION AND SUBSTITUTION:&lt;br /&gt;
# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format&lt;br /&gt;
sed &#39;s/.$//&#39; # assumes that all lines end with CR/LF&lt;br /&gt;
sed &#39;s/^M$//&#39; # in bash/tcsh, press Ctrl-V then Ctrl-M&lt;br /&gt;
sed &#39;s/\x0D$//&#39; # gsed 3.02.80, but top script is easier&lt;br /&gt;
&lt;br /&gt;
# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format&lt;br /&gt;
sed &quot;s/$/`echo -e \\\r`/&quot; # command line under ksh&lt;br /&gt;
sed &#39;s/$&#39;&quot;/`echo \\\r`/&quot; # command line under bash&lt;br /&gt;
sed &quot;s/$/`echo \\\r`/&quot; # command line under zsh&lt;br /&gt;
sed &#39;s/$/\r/&#39; # gsed 3.02.80&lt;br /&gt;
&lt;br /&gt;
# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format&lt;br /&gt;
sed &quot;s/$//&quot; # method 1&lt;br /&gt;
sed -n p # method 2&lt;br /&gt;
# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format Can only be done with UnxUtils sed, version 4.0.7 or higher. Cannot be done with other DOS versions of sed. Use &quot;tr&quot; instead.&lt;br /&gt;
sed &quot;s/\r//&quot; infile &amp;gt;outfile # UnxUtils&lt;br /&gt;
sed v4.0.7 or higher tr -d \r outfile # GNU tr version 1.22 or higher&lt;br /&gt;
# delete leading whitespace (spaces, tabs) from front of each line # aligns all text flush left&lt;br /&gt;
sed &#39;s/^[ \t]*//&#39; # see note on &#39;\t&#39; at end of file&lt;br /&gt;
# delete trailing whitespace (spaces, tabs) from end of each line&lt;br /&gt;
sed &#39;s/[ \t]*$//&#39; # see note on &#39;\t&#39; at end of file&lt;br /&gt;
# delete BOTH leading and trailing whitespace from each line&lt;br /&gt;
sed &#39;s/^[ \t]*//;s/[ \t]*$//&#39;&lt;br /&gt;
# insert 5 blank spaces at beginning of each line (make page offset)&lt;br /&gt;
sed &#39;s/^/ /&#39;&lt;br /&gt;
# align all text flush right on a 79-column width&lt;br /&gt;
sed -e :a -e &#39;s/^.\{1,78\}$/ &amp;amp;/;ta&#39; # set at 78 plus 1 space&lt;br /&gt;
# center all text in the middle of 79-column width. In method 1, spaces at the beginning of the line are significant, and trailing # spaces are appended at the end of the line. In method 2, spaces at # the beginning of the line are discarded in centering the line, and no trailing spaces appear at the end of lines.&lt;br /&gt;
sed -e :a -e &#39;s/^.\{1,77\}$/ &amp;amp; /;ta&#39; # method 1&lt;br /&gt;
sed -e :a -e &#39;s/^.\{1,77\}$/ &amp;amp;/;ta&#39; -e &#39;s/\( *\)\1/\1/&#39; # method 2&lt;br /&gt;
&lt;br /&gt;
# substitute (find and replace) &quot;foo&quot; with &quot;bar&quot; on each line&lt;br /&gt;
sed &#39;s/foo/bar/&#39; # replaces only 1st instance in a line&lt;br /&gt;
sed &#39;s/foo/bar/4&#39; # replaces only 4th instance in a line&lt;br /&gt;
sed &#39;s/foo/bar/g&#39; # replaces ALL instances in a line&lt;br /&gt;
sed &#39;s/\(.*\)foo\(.*foo\)/\1bar\2/&#39; # replace the next-to-last case&lt;br /&gt;
sed &#39;s/\(.*\)foo/\1bar/&#39; # replace only the last case&lt;br /&gt;
# substitute &quot;foo&quot; with &quot;bar&quot; ONLY for lines which contain &quot;baz&quot;&lt;br /&gt;
sed &#39;/baz/s/foo/bar/g&#39;&lt;br /&gt;
# substitute &quot;foo&quot; with &quot;bar&quot; EXCEPT for lines which contain &quot;baz&quot;&lt;br /&gt;
sed &#39;/baz/!s/foo/bar/g&#39;&lt;br /&gt;
# change &quot;scarlet&quot; or &quot;ruby&quot; or &quot;puce&quot; to &quot;red&quot;&lt;br /&gt;
sed &#39;s/scarlet/red/g;s/ruby/red/g;s/puce/red/g&#39; # most seds gsed &#39;s/scarlet\ruby\puce/red/g&#39; # GNU sed only&lt;br /&gt;
# reverse order of lines (emulates &quot;tac&quot;) bug/feature in HHsed v1.5 causes blank lines to be deleted&lt;br /&gt;
sed &#39;1!G;h;$!d&#39; # method 1&lt;br /&gt;
sed -n &#39;1!G;h;$p&#39; # method 2&lt;br /&gt;
&lt;br /&gt;
# reverse each character on the line (emulates &quot;rev&quot;)&lt;br /&gt;
sed &#39;/\n/!G;s/\(.\)\(.*\n\)/&amp;amp;\2\1/;//D;s/.//&#39;&lt;br /&gt;
# join pairs of lines side-by-side (like &quot;paste&quot;)&lt;br /&gt;
sed &#39;$!N;s/\n/ /&#39;&lt;br /&gt;
# if a line ends with a backslash, append the next line to it&lt;br /&gt;
sed -e :a -e &#39;/\\$/N; s/\\\n//; ta&#39;&lt;br /&gt;
# if a line begins with an equal sign, append it to the previous line # and replace the &quot;=&quot; with a single space&lt;br /&gt;
sed -e :a -e &#39;$!N;s/\n=/ /;ta&#39; -e &#39;P;D&#39;&lt;br /&gt;
# add commas to numeric strings, changing &quot;1234567&quot; to &quot;1,234,567&quot;&lt;br /&gt;
gsed &#39;:a;s/\B[0-9]\{3\}\&amp;gt;/,&amp;amp;/;ta&#39; # GNU sed&lt;br /&gt;
sed -e :a -e &#39;s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta&#39; # other seds&lt;br /&gt;
# add commas to numbers with decimal points and minus signs (GNU sed)&lt;br /&gt;
gsed &#39;:a;s/\(^\[^0-9.]\)\([0-9]\+\)\([0-9]\{3\}\)/\1\2,\3/g;ta&#39;&lt;br /&gt;
# add a blank line every 5 lines (after lines 5, 10, 15, 20, etc.) gsed &#39;0~5G&#39; # GNU sed only&lt;br /&gt;
sed &#39;n;n;n;n;G;&#39; # other seds&lt;br /&gt;
&lt;br /&gt;
SELECTIVE PRINTING OF CERTAIN LINES:&lt;br /&gt;
# print first 10 lines of file (emulates behavior of &quot;head&quot;)&lt;br /&gt;
sed 10q&lt;br /&gt;
# print first line of file (emulates &quot;head -1&quot;)&lt;br /&gt;
sed q&lt;br /&gt;
# print the last 10 lines of a file (emulates &quot;tail&quot;)&lt;br /&gt;
sed -e :a -e &#39;$q;N;11,$D;ba&#39;&lt;br /&gt;
# print the last 2 lines of a file (emulates &quot;tail -2&quot;)&lt;br /&gt;
sed &#39;$!N;$!D&#39;&lt;br /&gt;
# print the last line of a file (emulates &quot;tail -1&quot;)&lt;br /&gt;
sed &#39;$!d&#39; # method 1&lt;br /&gt;
sed -n &#39;$p&#39; # method 2&lt;br /&gt;
# print only lines which match regular expression (emulates &quot;grep&quot;)&lt;br /&gt;
sed -n &#39;/regexp/p&#39; # method 1&lt;br /&gt;
sed &#39;/regexp/!d&#39; # method 2&lt;br /&gt;
# print only lines which do NOT match regexp (emulates &quot;grep -v&quot;)&lt;br /&gt;
sed -n &#39;/regexp/!p&#39; # method 1, corresponds to above&lt;br /&gt;
sed &#39;/regexp/d&#39; # method 2, simpler syntax&lt;br /&gt;
# print the line immediately before a regexp, but not the line # containing the regexp&lt;br /&gt;
sed -n &#39;/regexp/{g;1!p;};h&#39;&lt;br /&gt;
# print the line immediately after a regexp, but not the line # containing the regexp&lt;br /&gt;
sed -n &#39;/regexp/{n;p;}&#39;&lt;br /&gt;
# print 1 line of context before and after regexp, with line number indicating where the regexp occurred (similar to &quot;grep -A1 -B1&quot;)&lt;br /&gt;
sed -n -e &#39;/regexp/{=;x;1!p;g;$!N;p;D;}&#39; -e h&lt;br /&gt;
# grep for AAA and BBB and CCC (in any order)&lt;br /&gt;
sed &#39;/AAA/!d; /BBB/!d; /CCC/!d&#39;&lt;br /&gt;
# grep for AAA and BBB and CCC (in that order)&lt;br /&gt;
sed &#39;/AAA.*BBB.*CCC/!d&#39;&lt;br /&gt;
# grep for AAA or BBB or CCC (emulates &quot;egrep&quot;)&lt;br /&gt;
sed -e &#39;/AAA/b&#39; -e &#39;/BBB/b&#39; -e &#39;/CCC/b&#39; -e d # most seds&lt;br /&gt;
gsed &#39;/AAA\BBB\CCC/!d&#39; # GNU sed only&lt;br /&gt;
# print paragraph if it contains AAA (blank lines separate paragraphs) HHsed v1.5 must insert a &#39;G;&#39; after &#39;x;&#39; in the next 3 scripts below&lt;br /&gt;
sed -e &#39;/./{H;$!d;}&#39; -e &#39;x;/AAA/!d;&#39;&lt;br /&gt;
# print paragraph if it contains AAA and BBB and CCC (in any order)&lt;br /&gt;
sed -e &#39;/./{H;$!d;}&#39; -e &#39;x;/AAA/!d;/BBB/!d;/CCC/!d&#39;&lt;br /&gt;
# print paragraph if it contains AAA or BBB or CCC&lt;br /&gt;
sed -e &#39;/./{H;$!d;}&#39; -e &#39;x;/AAA/b&#39; -e &#39;/BBB/b&#39; -e &#39;/CCC/b&#39; -e d&lt;br /&gt;
gsed &#39;/./{H;$!d;};x;/AAA\BBB\CCC/b;d&#39; # GNU sed only&lt;br /&gt;
# print only lines of 65 characters or longer&lt;br /&gt;
sed -n &#39;/^.\{65\}/p&#39;&lt;br /&gt;
# print only lines of less than 65 characters&lt;br /&gt;
sed -n &#39;/^.\{65\}/!p&#39; # method 1, corresponds to above&lt;br /&gt;
sed &#39;/^.\{65\}/d&#39; # method 2, simpler syntax&lt;br /&gt;
# print section of file from regular expression to end of file&lt;br /&gt;
sed -n &#39;/regexp/,$p&#39;&lt;br /&gt;
# print section of file based on line numbers (lines 8-12, inclusive)&lt;br /&gt;
sed -n &#39;8,12p&#39; # method 1&lt;br /&gt;
sed &#39;8,12!d&#39; # method 2&lt;br /&gt;
# print line number 52 sed -n &#39;52p&#39; # method 1&lt;br /&gt;
sed &#39;52!d&#39; # method 2&lt;br /&gt;
sed &#39;52q;d&#39; # method 3, efficient on large files&lt;br /&gt;
# beginning at line 3, print every 7th line&lt;br /&gt;
gsed -n &#39;3~7p&#39; # GNU sed only&lt;br /&gt;
sed -n &#39;3,${p;n;n;n;n;n;n;}&#39; # other seds&lt;br /&gt;
# print section of file between two regular expressions (inclusive)&lt;br /&gt;
sed -n &#39;/Iowa/,/Montana/p&#39; # case sensitive&lt;br /&gt;
&lt;br /&gt;
SELECTIVE DELETION OF CERTAIN LINES:&lt;br /&gt;
# print all of file EXCEPT section between 2 regular expressions&lt;br /&gt;
sed &#39;/Iowa/,/Montana/d&#39;&lt;br /&gt;
# delete duplicate, consecutive lines from a file (emulates &quot;uniq&quot;). First line in a set of duplicate lines is kept, rest are deleted.&lt;br /&gt;
sed &#39;$!N; /^\(.*\)\n\1$/!P; D&#39;&lt;br /&gt;
# delete duplicate, nonconsecutive lines from a file. Beware not to overflow the buffer size of the hold space, or else use GNU sed.&lt;br /&gt;
sed -n &#39;G; s/\n/&amp;amp;&amp;amp;/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P&#39;&lt;br /&gt;
# delete all lines except duplicate lines (emulates &quot;uniq -d&quot;).&lt;br /&gt;
sed &#39;$!N; s/^\(.*\)\n\1$/\1/; t; D&#39;&lt;br /&gt;
# delete the first 10 lines of a file&lt;br /&gt;
sed &#39;1,10d&#39;&lt;br /&gt;
# delete the last line of a file&lt;br /&gt;
sed &#39;$d&#39;&lt;br /&gt;
# delete the last 2 lines of a file&lt;br /&gt;
sed &#39;N;$!P;$!D;$d&#39;&lt;br /&gt;
# delete the last 10 lines of a file&lt;br /&gt;
sed -e :a -e &#39;$d;N;2,10ba&#39; -e &#39;P;D&#39; # method 1&lt;br /&gt;
sed -n -e :a -e &#39;1,10!{P;N;D;};N;ba&#39; # method 2&lt;br /&gt;
# delete every 8th line&lt;br /&gt;
gsed &#39;0~8d&#39; # GNU sed only&lt;br /&gt;
sed &#39;n;n;n;n;n;n;n;d;&#39; # other seds&lt;br /&gt;
# delete ALL blank lines from a file (same as &quot;grep &#39;.&#39; &quot;)&lt;br /&gt;
sed &#39;/^$/d&#39; # method 1&lt;br /&gt;
sed &#39;/./!d&#39; # method 2&lt;br /&gt;
# delete all CONSECUTIVE blank lines from file except the first; also deletes all blank lines from top and end of file (emulates &quot;cat -s&quot;)&lt;br /&gt;
sed &#39;/./,/^$/!d&#39; # method 1, allows 0 blanks at top, 1 at EOF&lt;br /&gt;
sed &#39;/^$/N;/\n$/D&#39; # method 2, allows 1 blank at top, 0 at EOF&lt;br /&gt;
# delete all CONSECUTIVE blank lines from file except the first 2:&lt;br /&gt;
sed &#39;/^$/N;/\n$/N;//D&#39;&lt;br /&gt;
# delete all leading blank lines at top of file&lt;br /&gt;
sed &#39;/./,$!d&#39;&lt;br /&gt;
# delete all trailing blank lines at end of file&lt;br /&gt;
sed -e :a -e &#39;/^\n*$/{$d;N;ba&#39; -e &#39;}&#39; # works on all seds&lt;br /&gt;
sed -e :a -e &#39;/^\n*$/N;/\n$/ba&#39; # ditto, except for gsed 3.02*&lt;br /&gt;
# delete the last line of each paragraph&lt;br /&gt;
sed -n &#39;/^$/{p;h;};/./{x;/./p;}&#39;&lt;br /&gt;
&lt;br /&gt;
SPECIAL APPLICATIONS:&lt;br /&gt;
# remove nroff overstrikes (char, backspace) from man pages. The &#39;echo&#39; command may need an -e switch if you use Unix System V or bash shell.&lt;br /&gt;
sed &quot;s/.`echo \\\b`//g&quot; # double quotes required for Unix environment&lt;br /&gt;
sed &#39;s/.^H//g&#39; # in bash/tcsh, press Ctrl-V and then Ctrl-H&lt;br /&gt;
sed &#39;s/.\x08//g&#39; # hex expression for sed v1.5&lt;br /&gt;
# get Usenet/e-mail message header&lt;br /&gt;
sed &#39;/^$/q&#39; # deletes everything after first blank line&lt;br /&gt;
# get Usenet/e-mail message body&lt;br /&gt;
sed &#39;1,/^$/d&#39; # deletes everything up to first blank line&lt;br /&gt;
# get Subject header, but remove initial &quot;Subject: &quot; portion&lt;br /&gt;
sed &#39;/^Subject: */!d; s///;q&#39;&lt;br /&gt;
# get return address header&lt;br /&gt;
sed &#39;/^Reply-To:/q; /^From:/h; /./d;g;q&#39;&lt;br /&gt;
# parse out the address proper. Pulls out the e-mail address by itself from the 1-line return address header (see preceding script)&lt;br /&gt;
sed &#39;s/ *(.*)//; s/&amp;gt;.*//; s/.*[:&amp;lt;] *//&#39; # add a leading angle bracket and space to each line (quote a message) sed &#39;s/^/&amp;gt; /&#39;&lt;br /&gt;
# delete leading angle bracket &amp;amp; space from each line (unquote a message)&lt;br /&gt;
sed &#39;s/^&amp;gt; //&#39;&lt;br /&gt;
# remove most HTML tags (accommodates multiple-line tags)&lt;br /&gt;
sed -e :a -e &#39;s/&amp;lt;[^&amp;gt;]*&amp;gt;//g;/zipup.bat dir /b *.txt sed &quot;s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/&quot;&amp;gt;&amp;gt;zipup.bat&lt;br /&gt;
&lt;br /&gt;
TYPICAL USE: Sed takes one or more editing commands and applies all ofthem, in sequence, to each line of input. After all the commands havebeen applied to the first input line, that line is output and a secondinput line is taken for processing, and the cycle repeats. Thepreceding examples assume that input comes from the standard inputdevice (i.e, the console, normally this will be piped input). One ormore filenames can be appended to the command line if the input doesnot come from stdin. Output is sent to stdout (the screen). Thus:&lt;br /&gt;
cat filename sed &#39;10q&#39; # uses piped input&lt;br /&gt;
sed &#39;10q&#39; filename # same effect, avoids a useless &quot;cat&quot;&lt;br /&gt;
sed &#39;10q&#39; filename &amp;gt; newfile # redirects output to disk&lt;br /&gt;
&lt;br /&gt;
On line selection or deletion in which you only need to output linesfrom the first part of the file, a &quot;quit&quot; command (q) in the scriptwill drastically reduce processing time for large files. Thus:&lt;br /&gt;
sed -n &#39;45,50p&#39; filename # print line nos. 45-50 of a file&lt;br /&gt;
sed -n &#39;51q;45,50p&#39; filename # same, but executes much faster&lt;br /&gt;
&lt;br /&gt;
CREDITS AND THANKS:http://student.northpark.edu/pemente/sed/sed1line.txt&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/useful-sed-one-liners.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-3714878226448178653</guid><pubDate>Sun, 01 Dec 2013 06:51:00 +0000</pubDate><atom:updated>2013-11-30T22:51:50.085-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Append Text to End in Unix File</category><category domain="http://www.blogger.com/atom/ns#">Change Whitespaces to a Single Space in Unix</category><category domain="http://www.blogger.com/atom/ns#">Delete Empty Lines in UNIX</category><category domain="http://www.blogger.com/atom/ns#">Print Even Lines in UNIX</category><category domain="http://www.blogger.com/atom/ns#">Print Odd Lines in UNIX</category><category domain="http://www.blogger.com/atom/ns#">Read a File Backwards in UNIX</category><title>Daily Weapons In Unix for Work -2 </title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
To reverse a file using awk and print next three lines after pattern match (Including pattern):&lt;br /&gt;
&lt;br /&gt;
awk &#39;{ a[i++] = $0 } END { for (j=i-1; j&amp;gt;=0;) print a[j--] }&#39; abcd.txt |sed -n &#39;/MANU/{p;n;p;n;p;n;p;}&#39; &amp;gt;abcd_new.txt&lt;br /&gt;
&lt;br /&gt;
(This can be used when you want to print 3 lines before pattern match, including pattern. Logic: reverse a file and print 3 lines after pattern match.)&lt;br /&gt;
&lt;br /&gt;
How to reverse a file using awk:&lt;br /&gt;
&lt;br /&gt;
awk &#39;{ a[i++] = $0 } END { for (j=i-1; j&amp;gt;=0;) print a[j--] }&#39; abcd.txt&lt;br /&gt;
&lt;br /&gt;
How to reverse a file using sed:&lt;br /&gt;
&lt;br /&gt;
sed -n &#39;1!G;h;$p&#39; abcd.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
how to get yesterday date in unix&lt;br /&gt;
YEST=`TZ=&quot;GMT+24&quot; date +&#39;%m/%d/%Y&#39;`; echo $YEST&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Replace Text : sed -e &quot;s/Old/New/g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Remove Text : sed -e &quot;s/Text//g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Remove Text From Front : sed -e &quot;s/^Text//g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Remove Text From End :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
sed -e &quot;s/Text\$//g&quot;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;s/Text$//g&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Insert Text in Front : sed -e &quot;s/^/Text/g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Append Text to End :&lt;/div&gt;
&lt;div&gt;
sed -e &quot;s/\$/Text/g&quot;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;s/$/Text/g&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Truncate :&lt;/div&gt;
&lt;div&gt;
sed -e &quot;s/Text.*//&quot;&lt;/div&gt;
&lt;div&gt;
cut -c5-8&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Downshift and Upshift :&lt;/div&gt;
&lt;div&gt;
tr &#39;[A-Z]&#39; &#39;[a-z]&#39;&lt;/div&gt;
&lt;div&gt;
tr &#39;[a-z]&#39; &#39;[A-Z]&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Change Tabs to Spaces : sed -e &quot;s/&amp;lt;tab&amp;gt;/ /g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Change Multiple Spaces to a Single Space :&lt;/div&gt;
&lt;div&gt;
sed -e &quot;s/ &amp;nbsp;*/ /g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Change Whitespaces to a Single Space :&lt;/div&gt;
&lt;div&gt;
sed -e &quot;s/[&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;][&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;]*/&amp;lt;space&amp;gt;/g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Leading Whitespaces:&lt;/div&gt;
&lt;div&gt;
sed -e &quot;s/^[&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;]*//g&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Trailing Whitespaces:&lt;/div&gt;
&lt;div&gt;
sed -e &#39;s/[&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;]*$//g&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Lines:&lt;/div&gt;
&lt;div&gt;
sed -e &quot;/Text/d&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
grep -v &quot;Text&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Empty Lines:&lt;/div&gt;
&lt;div&gt;
sed -e &#39;/^*$/d&#39;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;/^[&amp;lt;tab&amp;gt;&amp;lt;space&amp;gt;]*$/d&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete First Line:&lt;/div&gt;
&lt;div&gt;
sed -e &#39;1d&#39;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;1,7d&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Last Line : sed -e &#39;$d&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Print First Line :&lt;/div&gt;
&lt;div&gt;
sed -n &#39;1p&#39;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;2,$d&#39;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;1q&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Print Last Line :&lt;/div&gt;
&lt;div&gt;
sed -n &#39;$p&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Comments :&lt;/div&gt;
&lt;div&gt;
sed -e &#39;/^#/d&#39;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;s/#.*//&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delete Text Between Keywords :&lt;/div&gt;
&lt;div&gt;
sed -e &#39;/Keyword1/,/Keyword2/d&#39;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;/^Keyword1$/,/^Keyword2$/d&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Extract Text Between Keywords :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
sed -e &#39;/^Keyword1$/,/^Keyword2$/!d&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Print Odd Lines : cat -n file | &amp;nbsp;sed -e &#39;/.....[02468]/d&#39; -e &#39;s/^.......//&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Print Even Lines : cat -n file | &amp;nbsp;sed -e &#39;/.....[13579]/d&#39; -e &#39;s/^.......//&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Read a File Backwards : cat -n file | sort -nr | sed &#39;s/^.......//&#39;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Convert &amp;lt; &amp;gt; into LTGT : cat $* | sed -e &#39;s/&amp;lt;/\&amp;amp;lt;/g&#39; -e &#39;s/&amp;gt;/\&amp;amp;gt;/g&#39;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/daily-weapons-in-unix-for-work-2.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-1499755551407764077</guid><pubDate>Sun, 01 Dec 2013 06:49:00 +0000</pubDate><atom:updated>2013-11-30T22:49:21.551-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">insert a blank line above every line which matches &quot;regex&quot;</category><category domain="http://www.blogger.com/atom/ns#">Joining two files parallely using awk:</category><category domain="http://www.blogger.com/atom/ns#">sort a delimited file on the basis of a column</category><title>Daily Weapons of Unix in Office</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Count the number of occurances of a pattern in a file using awk&lt;br /&gt;
awk &#39;{ for (i=1;i&amp;lt;=NF;i++) if ( $i == &quot;word&quot; ) count++ } END{print count}&#39; filename&lt;br /&gt;
This will print the count of the occurance of &amp;nbsp;a pattern &quot;word&quot; in a file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to compare the values of a column in awk in a same file and consecutive lines..&lt;br /&gt;
If one would like to compare the values of 2nd column of consecutive lines of same file in such a way so that if the difference between first value and second value is more than 100 it should print complete line else ignore line.&lt;br /&gt;
&lt;br /&gt;
Input File:&lt;br /&gt;
=======&lt;br /&gt;
&lt;br /&gt;
ABC 2500&lt;br /&gt;
ABCD 123&lt;br /&gt;
XYZ 122&lt;br /&gt;
WXYZ 2565&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Desired Output:&lt;br /&gt;
==========&lt;br /&gt;
&lt;br /&gt;
ABC 2500 (i.e. difference between 2500 and 123 is greater than 100 here)&lt;br /&gt;
XYZ 122 (i.e. difference between 122 and 2565 is greater than 100 here)&lt;br /&gt;
&lt;br /&gt;
Command:&lt;br /&gt;
=======&lt;br /&gt;
&lt;br /&gt;
awk &#39;NR % 2 != 0 {a=$1; b=$2} NR % 2 == 0 {if (b - $2 &amp;gt; 100 || $2 - b &amp;gt; 100){print a,b}}&#39; inputfile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Count the number of files in each directory recursively&lt;br /&gt;
find ./ -type d -exec sh -c &quot;echo -n {} &#39; &#39; ; ls -l {} | wc -l&quot; \;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use awk in following cases&lt;br /&gt;
&lt;br /&gt;
Joining two files parallely using awk:&lt;br /&gt;
========================&lt;br /&gt;
awk &#39;NR==FNR{a[NR]=$0; next} {print a[FNR], $0}&#39; file1.txt file2.txt&lt;br /&gt;
&lt;br /&gt;
Changing extension of all .txt to .sh:&lt;br /&gt;
========================&lt;br /&gt;
for i in *.txt;do mv &quot;$i&quot; &quot;${i%.txt}&quot;.sh;done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Print 3 lines before and 5 lines after pattern match abcd in a file a.txt&lt;br /&gt;
In Linux:&lt;br /&gt;
&lt;br /&gt;
awk &#39;c--&amp;gt;0;$0~s{if(b)for(c=b+1;c&amp;gt;1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}&#39; b=3 a=5 s=&quot;abcd&quot; a.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ftp in UNIX&lt;br /&gt;
ftp -n 10.200.120.12 &amp;lt;&amp;lt; EOF&lt;br /&gt;
quote user username&lt;br /&gt;
quote pass password&lt;br /&gt;
cd /path/to/directory/&lt;br /&gt;
prompt off&lt;br /&gt;
put dump.txt&lt;br /&gt;
exit&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Print one line before pattern match using sed in UNIX.&lt;br /&gt;
sed -n -e &#39;/manu/{x;p;x;p;}&#39; -e h test.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
sort a delimited file on the basis of a column&lt;br /&gt;
sort -t&quot;:&quot; -k3 filename.txt&lt;br /&gt;
&lt;br /&gt;
(The above will sort a file filename.txt which is &quot;:&quot; delimited on the basis of third column.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Print every 6th line of a file ..&lt;br /&gt;
The below awk command will print every 6th line of a file test.txt starting from line number one.&lt;br /&gt;
&lt;br /&gt;
awk &#39;{if(NR%6==1) print $0}&#39; test.txt&lt;br /&gt;
&lt;br /&gt;
(Note: Print every nth line using awk.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# insert a blank line above every line which matches &quot;regex&quot;&lt;br /&gt;
&amp;nbsp;sed &#39;/regex/{x;p;x;}&#39; OR &amp;nbsp;sed &#39;/regex/{x;G;}&#39;&lt;br /&gt;
&lt;br /&gt;
# insert a blank line below every line which matches &quot;regex&quot;&lt;br /&gt;
&amp;nbsp;sed &#39;/regex/G&#39;&lt;br /&gt;
&lt;br /&gt;
# insert a blank line above and below every line which matches &quot;regex&quot;&lt;br /&gt;
&amp;nbsp;sed &#39;/regex/{x;p;x;G;}&#39;&lt;br /&gt;
&lt;br /&gt;
# remove the header of a file&lt;br /&gt;
sed &#39;/1,1d&#39; filename&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/daily-weapons-of-unix-in-office.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-3407707547023120501</guid><pubDate>Sun, 01 Dec 2013 06:46:00 +0000</pubDate><atom:updated>2013-11-30T22:46:58.479-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AWK</category><category domain="http://www.blogger.com/atom/ns#">Difference between AWK and SED</category><category domain="http://www.blogger.com/atom/ns#">SED</category><category domain="http://www.blogger.com/atom/ns#">Unix Utilities</category><title>Difference between AWK and SED command</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;SED (which stands for Stream EDitor) is a simple but&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;powerful computer program used to apply various&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;pre-specified textual transformations to a sequential stream&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;of text data. It reads input files line by line, edits each line according to rules specified in its simple language (the sed script), and then outputs the line.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
AWK is a complete pattern scanning and processing language, it is most commonly used as a Unix command-line filter to reformat the output of other commands. &amp;nbsp;For example, to print only the second and sixth fields of the date command (the month and year) with a space separating them, at the Unix prompt, you would enter: date | awk ‘{print $2 ” ” $6}’&lt;/div&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;====================================================&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: arial; font-size: small;&quot;&gt;sed reads from standard input and/or file(s), applies specified&amp;nbsp;changes which are typically mostly editing changes, and&amp;nbsp;writes to&amp;nbsp;standard output. It is relatively similar to the text editor&lt;br /&gt;ed(1),&amp;nbsp;except in the case of sed it doesn&#39;t alter its input&amp;nbsp;file(s)*, but&amp;nbsp;writes the data to standard output, and sed also has some&amp;nbsp;commands&amp;nbsp;which ed does not have (and in most cases wouldn&#39;t be&amp;nbsp;suitable for or&amp;nbsp;make sense for ed). sed&#39;s commands are mostly limited to editing&amp;nbsp;type commands.&lt;br /&gt;&lt;br /&gt;awk is sort of like an interpreted somewhat C-like language with&amp;nbsp;added built-in functionality for dealing with strings and&amp;nbsp;patterns.&amp;nbsp;Though not a fully general purpose programming language, awk&amp;nbsp;is much&amp;nbsp;closer to such than sed.&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/difference-between-awk-and-sed-command.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-582030712060695628</guid><pubDate>Sun, 01 Dec 2013 06:37:00 +0000</pubDate><atom:updated>2013-11-30T22:37:37.470-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">lsof In Unix</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Unix Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Unix Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Unix Interview Questions and Commands</category><category domain="http://www.blogger.com/atom/ns#">Unix Sed Command</category><category domain="http://www.blogger.com/atom/ns#">Unix Tricks</category><title>Unix Interview Questions and Commands</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1. How do you find which processes are using a particular file?&lt;br /&gt;
&lt;br /&gt;
By using lsof command in UNIX. It will list down PID of all the processes which are using a particular file.&lt;br /&gt;
&lt;br /&gt;
2. How do you find which remote hosts are connecting to your host on a particular port say 10123?&lt;br /&gt;
&lt;br /&gt;
By using netstat command&lt;br /&gt;
&lt;br /&gt;
For example: execute netstat -a | grep &quot;port&quot; and it will list the entire hosts which are connected to this host on port 10123.&lt;br /&gt;
&lt;br /&gt;
3. How to tell if my process is running in Unix?&lt;br /&gt;
&lt;br /&gt;
You can list down all the running processes using [ps] command. Then you can “grep” your user name or process name to see if the process is running.&lt;br /&gt;
&lt;br /&gt;
4. What is ephemeral port in UNIX?&lt;br /&gt;
&lt;br /&gt;
Ephemeral ports are port used by Operating system for client sockets. There is a specific range on which OS can open any port specified by ephemeral port range.&lt;br /&gt;
&lt;br /&gt;
5. How to list down file/folder lists alphabetically?&lt;br /&gt;
&lt;br /&gt;
Normally [ls –lt] command lists down file/folder list sorted by modified time. If you want to list then alphabetically, then you should simply specify: [ls –l]&lt;br /&gt;
&lt;br /&gt;
6. If one process is inserting data into your MySQL database? How will you check how many rows inserted into every second?&lt;br /&gt;
&lt;br /&gt;
By using &quot;watch&quot; command in UNIX&lt;br /&gt;
&lt;br /&gt;
7. There is a file Unix_Test.txt which contains words &quot;Unix&quot;. How will you replace all Unix to UNIX?&lt;br /&gt;
&lt;br /&gt;
By using SED command in UNIX&lt;br /&gt;
&lt;br /&gt;
For example: you can execute sed s/Unix/UNIX/g fileName.&lt;br /&gt;
&lt;br /&gt;
8. You have a tab separated file which contains Name, Address and Phone Number. List down all Phone Number without their name and addresses?&lt;br /&gt;
&lt;br /&gt;
By using either AWK or CUT command.&lt;br /&gt;
&lt;br /&gt;
9. How to check if the last command was successful in Unix?&lt;br /&gt;
&lt;br /&gt;
To check the status of last executed command in UNIX, you can check the value of an inbuilt bash variable [$?]. See the below example:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; echo $?&lt;br /&gt;
&lt;br /&gt;
10. How to check all the running processes in Unix?&lt;br /&gt;
&lt;br /&gt;
The standard command to see this is [ps]. But [ps] only shows you the snapshot of the processes at that instance. If you need to monitor the processes for a certain period of time and need to refresh the results in each interval, consider using the [top] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; ps –ef&lt;br /&gt;
&lt;br /&gt;
If you wish to see the % of memory usage and CPU usage, then consider the below switches:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; ps aux&lt;br /&gt;
&lt;br /&gt;
If you wish to use this command inside some shell script, or if you want to customize the output of [ps] command, you may use “-o” switch like below. By using “-o” switch, you can specify the columns that you want [ps] to print out.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;ps -e -o stime,user,pid,args,%mem,%cpu&lt;br /&gt;
&lt;br /&gt;
11 Your application home directory is full? How will you find which directory is taking how much space?&lt;br /&gt;
&lt;br /&gt;
By using disk usage (DU) command in Unix&lt;br /&gt;
&lt;br /&gt;
For example du –sh . | grep G &amp;nbsp;will list down all the directories which have GIGS in Size.&lt;br /&gt;
&lt;br /&gt;
12. How do you find for how many days your Server is up?&lt;br /&gt;
&lt;br /&gt;
By using uptime command in UNIX&lt;br /&gt;
&lt;br /&gt;
13. How to check if a file is present in a particular directory in Unix?&lt;br /&gt;
&lt;br /&gt;
Using command, we can do it in many ways. Based on what we have learnt so far, we can make use of [ls] and [$?] command to do this. See below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; ls –l file.txt; echo $?&lt;br /&gt;
&lt;br /&gt;
If the file exists, the [ls] command will be successful. Hence [echo $?] will print 0. If the file does not exist, then [ls] command will fail and hence [echo $?] will print 1.&lt;br /&gt;
&lt;br /&gt;
14. You have an IP address in your network. How will you find hostname and vice versa?&lt;br /&gt;
&lt;br /&gt;
By using nslookup command in UNIX&lt;br /&gt;
&lt;br /&gt;
15. How to execute a database stored procedure from Shell script?&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; SqlReturnMsg=`sqlplus -s username/password@database&amp;lt;&amp;lt;EOF&lt;br /&gt;
BEGIN&lt;br /&gt;
Proc_Your_Procedure(… your-input-parameters …);&lt;br /&gt;
END;&lt;br /&gt;
/&lt;br /&gt;
EXIT;&lt;br /&gt;
EOF`&lt;br /&gt;
$&amp;gt; echo $SqlReturnMsg&lt;br /&gt;
&lt;br /&gt;
16. How to check the command line arguments in a UNIX command in Shell Script?&lt;br /&gt;
&lt;br /&gt;
In a bash shell, you can access the command line arguments using $0, $1, $2, … variables, where $0 prints the command name, $1 prints the first input parameter of the command, $2 the second input parameter of the command and so on.&lt;br /&gt;
&lt;br /&gt;
17. How to fail a shell script programmatically?&lt;br /&gt;
&lt;br /&gt;
Just put an [exit] command in the shell script with return value other than 0. This is because the exit code of successful Unix program is zero. So, suppose if you write exit -1 inside your program, then your program will throw an error and exit immediately.&lt;br /&gt;
&lt;br /&gt;
18. How to print/display the first line of a file?&lt;br /&gt;
&lt;br /&gt;
There are many ways to do this. However the easiest way to display the first line of a file is using the [head] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; head -1 file.txt&lt;br /&gt;
&lt;br /&gt;
If you specify [head -2] then it would print first 2 records of the file.&lt;br /&gt;
&lt;br /&gt;
Another way can be by using [sed] command. [Sed] is a very powerful text editor which can be used for various text manipulation purposes like this.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed &#39;2,$ d&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
How does the above command work? The &#39;d&#39; parameter basically tells [sed] to delete all the records from display from line 2 to last line of the file (last line is represented by $ symbol). Of course it does not actually delete those lines from the file, it just does not display those lines in standard output screen. So you only see the remaining line which is the 1st line.]&lt;br /&gt;
&lt;br /&gt;
19. How to print/display the last line of a file?&lt;br /&gt;
&lt;br /&gt;
The easiest way is to use the [tail] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; tail -1 file.txt&lt;br /&gt;
&lt;br /&gt;
If you want to do it using [sed] command, here is what you should write:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed -n &#39;$ p&#39; test&lt;br /&gt;
&lt;br /&gt;
From our previous answer, we already know that &#39;$&#39; stands for the last line of the file. So &#39;$ p&#39; basically prints (p for print) the last line in standard output screen. &#39;-n&#39; switch takes [sed] to silent mode so that [sed] does not print anything else in the output.&lt;br /&gt;
&lt;br /&gt;
20. How to display n-th line of a file?&lt;br /&gt;
&lt;br /&gt;
The easiest way to do it will be by using [sed]. Based on what we already know about [sed] from our previous examples, we can quickly deduce this command:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;&amp;lt;n&amp;gt; p&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
You need to replace &amp;lt;n&amp;gt; with the actual line number. So if you want to print the 4th line, the command will be&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;4 p&#39; test&lt;br /&gt;
&lt;br /&gt;
Of course you can do it by using [head] and [tail] command as well like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; head -&amp;lt;n&amp;gt; file.txt | tail -1&lt;br /&gt;
&lt;br /&gt;
You need to replace &amp;lt;n&amp;gt; with the actual line number. So if you want to print the 4th line, the command will be&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; head -4 file.txt | tail -1&lt;br /&gt;
&lt;br /&gt;
21. How to remove the first line / header from a file?&lt;br /&gt;
&lt;br /&gt;
We already know how [sed] can be used to delete a certain line from the output – by using the&#39;d&#39; switch. So if we want to delete the first line the command should be:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed &#39;1 d&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
But the issue with the above command is, it just prints out all the lines except the first line of the file on the standard output. It does not really change the file in-place. So if you want to delete the first line from the file itself, you have two options.&lt;br /&gt;
&lt;br /&gt;
Either you can redirect the output of the file to some other file and then rename it back to original file like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed &#39;1 d&#39; file.txt &amp;gt; new_file.txt&lt;br /&gt;
$&amp;gt; mv new_file.txt file.txt&lt;br /&gt;
&lt;br /&gt;
Or, you can use an inbuilt [sed] switch &#39;–i&#39; which changes the file in-place. See below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;1 d&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
22. How to remove the last line/ trailer from a file in Unix script?&lt;br /&gt;
&lt;br /&gt;
Always remember that [sed] switch &#39;$&#39; refers to the last line. So using this knowledge we can deduce the below command:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;$ d&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
23. How to remove certain lines from a file in Unix?&lt;br /&gt;
&lt;br /&gt;
If you want to remove line &amp;lt;m&amp;gt; to line &amp;lt;n&amp;gt; from a given file, you can accomplish the task in the similar method shown above. Here is an example:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;5,7 d&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
The above command will delete line 5 to line 7 from the file file.txt&lt;br /&gt;
&lt;br /&gt;
24. How to remove the last n-th line from a file?&lt;br /&gt;
&lt;br /&gt;
This is bit tricky. Suppose your file contains 100 lines and you want to remove the last 5 lines. Now if you know how many lines are there in the file, then you can simply use the above shown method and can remove all the lines from 96 to 100 like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;96,100 d&#39; file.txt &amp;nbsp; # alternative to command [head -95 file.txt]&lt;br /&gt;
&lt;br /&gt;
But not always you will know the number of lines present in the file (the file may be generated dynamically, etc.) In that case there are many different ways to solve the problem. There are some ways which are quite complex and fancy. But let&#39;s first do it in a way that we can understand easily and remember easily. Here is how it goes:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; tt=`wc -l file.txt | cut -f1 -d&#39; &#39;`;sed –i &quot;`expr $tt - 4`,$tt d&quot; test&lt;br /&gt;
&lt;br /&gt;
As you can see there are two commands. The first one (before the semi-colon) calculates the total number of lines present in the file and stores it in a variable called “tt”. The second command (after the semi-colon), uses the variable and works in the exact way as shown in the previous example.&lt;br /&gt;
&lt;br /&gt;
25. How to check the length of any line in a file?&lt;br /&gt;
&lt;br /&gt;
We already know how to print one line from a file which is this:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;&amp;lt;n&amp;gt; p&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;n&amp;gt; is to be replaced by the actual line number that you want to print. Now once you know it, it is easy to print out the length of this line by using [wc] command with &#39;-c&#39; switch.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;35 p&#39; file.txt | wc –c&lt;br /&gt;
&lt;br /&gt;
The above command will print the length of 35th line in the file.txt.&lt;br /&gt;
&lt;br /&gt;
26. How to get the nth word of a line in Unix?&lt;br /&gt;
&lt;br /&gt;
Assuming the words in the line are separated by space, we can use the [cut] command. [cut] is a very powerful and useful command and it&#39;s real easy. All you have to do to get the n-th word from the line is issue the following command:&lt;br /&gt;
&lt;br /&gt;
cut –f&amp;lt;n&amp;gt; -d&#39; &#39;&lt;br /&gt;
&lt;br /&gt;
&#39;-d&#39; switch tells [cut] about what is the delimiter (or separator) in the file, which is space &#39; &#39; in this case. If the separator was comma, we could have written -d&#39;,&#39; then. So, suppose I want find the 4th word from the below string: “A quick brown fox jumped over the lazy cat”, we will do something like this:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; echo “A quick brown fox jumped over the lazy cat” | cut –f4 –d&#39; &#39;&lt;br /&gt;
&lt;br /&gt;
And it will print “fox”&lt;br /&gt;
&lt;br /&gt;
27. How to reverse a string in unix?&lt;br /&gt;
&lt;br /&gt;
Pretty easy. Use the [rev] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; echo &quot;unix&quot; | rev&lt;br /&gt;
&lt;br /&gt;
xinu&lt;br /&gt;
&lt;br /&gt;
28. How to get the last word from a line in Unix file?&lt;br /&gt;
&lt;br /&gt;
We will make use of two commands that we learnt above to solve this. The commands are [rev] and [cut]. Here we go.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s imagine the line is: “C for Cat”. We need “Cat”. First we reverse the line. We get “taC rof C”. Then we cut the first word, we get &#39;taC&#39;. And then we reverse it again.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;echo &quot;C for Cat&quot; | rev | cut -f1 -d&#39; &#39; | rev&lt;br /&gt;
&lt;br /&gt;
Cat&lt;br /&gt;
&lt;br /&gt;
29. How to get the n-th field from a Unix command output?&lt;br /&gt;
&lt;br /&gt;
We know we can do it by [cut]. Like below command extracts the first field from the output of [wc –c] command&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;wc -c file.txt | cut -d&#39; &#39; -f1&lt;br /&gt;
&lt;br /&gt;
But I want to introduce one more command to do this here. That is by using [awk] command. [awk] is a very powerful command for text pattern scanning and processing. Here we will see how may we use of [awk] to extract the first field (or first column) from the output of another command. Like above suppose I want to print the first column of the [wc –c] output. Here is how it goes like this:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;wc -c file.txt | awk &#39; &#39;&#39;{print $1}&#39;&lt;br /&gt;
&lt;br /&gt;
The basic syntax of [awk] is like this:&lt;br /&gt;
&lt;br /&gt;
awk &#39;pattern space&#39;&#39;{action space}&#39;&lt;br /&gt;
&lt;br /&gt;
The pattern space can be left blank or omitted, like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;wc -c file.txt | awk &#39;{print $1}&#39;&lt;br /&gt;
&lt;br /&gt;
In the action space, we have asked [awk] to take the action of printing the first column ($1).&lt;br /&gt;
&lt;br /&gt;
30. How to replace the n-th line in a file with a new line in Unix?&lt;br /&gt;
&lt;br /&gt;
This can be done in two steps. The first step is to remove the n-th line. And the second step is to insert a new line in n-th line position. Here we go.&lt;br /&gt;
&lt;br /&gt;
Step 1: remove the n-th line&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;sed -i&#39;&#39; &#39;10 d&#39; file.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; # d stands for delete&lt;br /&gt;
&lt;br /&gt;
Step 2: insert a new line at n-th line position&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;sed -i&#39;&#39; &#39;10 i This is the new line&#39; file.txt &amp;nbsp; &amp;nbsp; # i stands for insert&lt;br /&gt;
&lt;br /&gt;
31. How to show the non-printable characters in a file?&lt;br /&gt;
&lt;br /&gt;
Open the file in VI editor. Go to VI command mode by pressing [Escape] and then [:]. Then type [set list]. This will show you all the non-printable characters, e.g. Ctrl-M characters (^M) etc., in the file.&lt;br /&gt;
&lt;br /&gt;
32. How to zip a file in Linux?&lt;br /&gt;
&lt;br /&gt;
Use inbuilt [zip] command in Linux&lt;br /&gt;
&lt;br /&gt;
33. How to unzip a file in Linux?&lt;br /&gt;
&lt;br /&gt;
Use inbuilt [unzip] command in Linux.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; unzip –j file.zip&lt;br /&gt;
&lt;br /&gt;
34. How to test if a zip file is corrupted in Linux?&lt;br /&gt;
&lt;br /&gt;
Use “-t” switch with the inbuilt [unzip] command&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; unzip –t file.zip&lt;br /&gt;
&lt;br /&gt;
35. How to check if a file is zipped in Unix?&lt;br /&gt;
&lt;br /&gt;
In order to know the file type of a particular file use the [file] command like below:&lt;br /&gt;
$&amp;gt; file file.txt&lt;br /&gt;
file.txt: ASCII text&lt;br /&gt;
If you want to know the technical MIME type of the file, use “-i” switch.&lt;br /&gt;
$&amp;gt;file -i file.txt&lt;br /&gt;
file.txt: text/plain; charset=us-ascii&lt;br /&gt;
If the file is zipped, following will be the result&lt;br /&gt;
$&amp;gt; file –i file.zip&lt;br /&gt;
file.zip: application/x-zip&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/unix-interview-questions-and-commands.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-4397774842017536731</guid><pubDate>Sun, 01 Dec 2013 06:30:00 +0000</pubDate><atom:updated>2013-11-30T22:30:55.242-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AWK</category><category domain="http://www.blogger.com/atom/ns#">Awk One Liners for Unix Interviews</category><category domain="http://www.blogger.com/atom/ns#">Awk Tricks</category><category domain="http://www.blogger.com/atom/ns#">Unix AWK</category><category domain="http://www.blogger.com/atom/ns#">Unix AWK Command</category><title>Awesome Awk One Liners for Unix Interviews</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1.To Negate some lines with AWK:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;These are called awk one liners. The First trick for today is how to negate some rows while using awk.&lt;br /&gt;
&lt;br /&gt;
The Trick is : awk -F ” ” ‘NR&amp;gt;5 &amp;amp;&amp;amp; NR&amp;lt;7{print $1,$2,$3}’ 1.txt&lt;br /&gt;
&lt;br /&gt;
Note : This question will mostly asked in interviews where you will be asked to print some parameters from a file mostly a log file where in you will be asked to negate some rows herein refered to as records in awk. The above command here performs the following action. The field separator mostly called as delimiter here will be a space and then it will negate all the records and will only iterate through line numbers five through seven and then print the first second and third parameter.&lt;br /&gt;
&lt;br /&gt;
2. To Take only a few Lines:&lt;br /&gt;
&lt;br /&gt;
How would you print only lines match between Rahul and Abhishek using awk? Considering your file names.txt contains :&lt;br /&gt;
Rahul&lt;br /&gt;
Sahil&lt;br /&gt;
Geetika&lt;br /&gt;
Mamta&lt;br /&gt;
Abhishek&lt;br /&gt;
and the expected output should be like :&lt;br /&gt;
Sahil&lt;br /&gt;
Geetika&lt;br /&gt;
Mamta&lt;br /&gt;
&lt;br /&gt;
The Trick is : $ awk ‘/Rahul/{ P=1; next } /Abhishek/ {exit} P’ names.txt&lt;br /&gt;
&lt;br /&gt;
3. Context Addressing in AWK:&lt;br /&gt;
&lt;br /&gt;
The above command will give you the desired output. Just try. If the Interviewer asks you what is this called, Just say this is called the CONTEXT addressing in awk. The interviewer might also be interested in asking you to print a certain range of lines from a file where in you do not have a pattern defined. We all know awk works on the principle of condition { actions }. Where condition is typically an expression and action is a series of commands. The input is split into records, where by default records are separated by newline characters so that the input is split into lines. So we know the context addressing can be used just like grep, so here you go.&lt;br /&gt;
&lt;br /&gt;
The Trick is : awk ‘$0 ~ /pattern/ {print $0}’&lt;br /&gt;
&lt;br /&gt;
4. Taking a range of records:&lt;br /&gt;
&lt;br /&gt;
Suppose one wants to print all the lines in a file that match some pattern, the above code should be used.Lets suppose he wants you to print logs from line number 15000 to 16000.Just give him a simple blunt reply.&lt;br /&gt;
&lt;br /&gt;
The Trick is &amp;nbsp;: head -16000 filename | tail -1000.&lt;br /&gt;
&lt;br /&gt;
5. Deleting only files :&lt;br /&gt;
&lt;br /&gt;
Now the interviewer might be tempted to ask you to delete all the files in the current directory with awk.&lt;br /&gt;
&lt;br /&gt;
The Trick is &amp;nbsp;: ls -l|awk ‘$1!~/^drwx/{print $9}’|xargs rm&lt;br /&gt;
&lt;br /&gt;
6. Removing Duplicates without sorting :&lt;br /&gt;
&lt;br /&gt;
Be careful when trying this out in your home directory. This will remove all the files. awk syntax is not the same in every Unix system, but there is a way to learning how is it in our particular system: man awk. Now lets see our last trick, this talks about deleting the duplicate entries in file without sorting. There are thousand ways of doing one thing in unix lets see a couple of them. Suppose your file text.txt has contents the below contents.&lt;br /&gt;
&lt;br /&gt;
/users/env&amp;gt; cat test.txt&lt;br /&gt;
abcd&lt;br /&gt;
efgh&lt;br /&gt;
ijkl&lt;br /&gt;
mnop&lt;br /&gt;
abcd&lt;br /&gt;
/users/env &amp;gt; cat test.txt |awk !’x[$0]++’&lt;br /&gt;
abcd&lt;br /&gt;
efgh&lt;br /&gt;
ijkl&lt;br /&gt;
mnop&lt;br /&gt;
&lt;br /&gt;
Now this one lines removes the duplicate without sorting them.&lt;br /&gt;
&lt;br /&gt;
Taken From&amp;nbsp;&lt;a href=&quot;http://www.computerandyou.net/2012/07/six-simple-and-awesome-awk-one-liners-for-unix-interviews/&quot;&gt;http://www.computerandyou.net/2012/07/six-simple-and-awesome-awk-one-liners-for-unix-interviews/&lt;/a&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/awesome-awk-one-liners-for-unix.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-3334945888603373041</guid><pubDate>Sun, 01 Dec 2013 06:27:00 +0000</pubDate><atom:updated>2013-11-30T22:27:53.256-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AWK Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">AWK One Liners</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Unix Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Unix AWK Command</category><category domain="http://www.blogger.com/atom/ns#">Unix Interview Questions</category><title>AWK Interview Questions 1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Awk is powerful tool in Unix. Awk is an excellent tool for processing the files which have data arranged in rows and columns format. It is a good filter and report writer.&lt;br /&gt;
1. How to run awk command specified in a file?&lt;br /&gt;
awk -f filename&lt;br /&gt;
&lt;br /&gt;
2. Write a command to print the squares of numbers from 1 to 10 using awk command&lt;br /&gt;
awk &#39;BEGIN { for(i=1;i&amp;lt;=10;i++) {print &quot;square of&quot;,i,&quot;is&quot;,i*i;}}&#39;&lt;br /&gt;
&lt;br /&gt;
3. Write a command to find the sum of bytes (size of file) of all files in a directory.&lt;br /&gt;
ls -l | awk &#39;BEGIN {sum=0} {sum = sum + $5} END {print sum}&#39;&lt;br /&gt;
&lt;br /&gt;
4. In the text file, some lines are delimited by colon and some are delimited by space. Write a command to print the third field of each line.&lt;br /&gt;
&lt;br /&gt;
awk &#39;{ if( $0 ~ /:/ ) { FS=&quot;:&quot;; } else { FS =&quot; &quot;; } print $3 }&#39; filename&lt;br /&gt;
&lt;br /&gt;
5. Write a command to print the line number before each line?&lt;br /&gt;
awk &#39;{print NR, $0}&#39; filename&lt;br /&gt;
&lt;br /&gt;
6. Write a command to print the second and third line of a file without using NR.&lt;br /&gt;
awk &#39;BEGIN {RS=&quot;&quot;;FS=&quot;\n&quot;} {print $2,$3}&#39; filename&lt;br /&gt;
&lt;br /&gt;
7. Write a command to print zero byte size files?&lt;br /&gt;
ls -l | awk &#39;/^-/ {if ($5 !=0 ) print $9 }&#39;&lt;br /&gt;
&lt;br /&gt;
8. Write a command to rename the files in a directory with &quot;_new&quot; as postfix?&lt;br /&gt;
ls -F | awk &#39;{print &quot;mv &quot;$1&quot; &quot;$1&quot;.new&quot;}&#39; | sh&lt;br /&gt;
&lt;br /&gt;
9. Write a command to print the fields in a text file in reverse order?&lt;br /&gt;
awk &#39;BEGIN {ORS=&quot;&quot;} { for(i=NF;i&amp;gt;0;i--) print $i,&quot; &quot;; print &quot;\n&quot;}&#39; filename&lt;br /&gt;
&lt;br /&gt;
10. Write a command to find the total number of lines in a file without using NR&lt;br /&gt;
awk &#39;BEGIN {sum=0} {sum=sum+1} END {print sum}&#39; filename&lt;br /&gt;
&lt;br /&gt;
Another way to print the number of lines is by using the NR. The command is&lt;br /&gt;
awk &#39;END{print NR}&#39; filename&amp;nbsp;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/awk-interview-questions-1.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-8129135096589113072</guid><pubDate>Mon, 25 Nov 2013 16:07:00 +0000</pubDate><atom:updated>2013-11-25T08:07:30.597-08:00</atom:updated><title>perl coding</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $Log_Path;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $OPLOG_PATH;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $Start_Time_Dur;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $End_Time_Dur;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $Category ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $op_file ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (scalar @ARGV &amp;lt; 2) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; die &quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ***********************************************************&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; USAGE:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Option1 : $0 Log_File_Name Flag&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Option2 : $0 Log_File_Name Flag ArrayCounter&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Help :&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; perl $0 Log_File_Name --flags&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flags are:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Help &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Suggests the usage for the script and the flags available&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Default &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1. Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2. Top ten URL&#39;s Response Time wise, Top Ten URL Download Wise, Hourly Frequency of load&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Hourly &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Outputs Hourly hit/response time/download amount from URL&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --CategoryWise &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Outputs category wise hit/response time/download amount from URL&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Categ_Hourly &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Outputs Hourly as well as Category wise hit/response time/download amount from URL&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Download &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Outputs download amount from URL&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Cat_Download &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Outputs Category wise download amount from URL&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Hourly_Download &amp;nbsp; &amp;nbsp; Outputs Hourly download amount from URL&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --Create_Hourly_Logs &amp;nbsp;This Creates the Hourly Log as per the requirement&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --All3Ip &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Output&#39;s 3 ip&#39;s which are present at IP field&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --URL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output&#39;s the unique URL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --HperIP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Output&#39;s Hit&#39;s Per Ip&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $Log_Path = $ARGV[0] || &#39;&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; use strict;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $array_counter = $ARGV[2] || &#39;15&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Number of Rows Requested : &quot;.$array_counter.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my %hash1 = ();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @array1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $output_file;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @arrays;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @hourly_log;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $scalar1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my %seen = ();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $tim;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $waqt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $series;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $text;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @hitsip;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @respons;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @qwe;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @dada;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @highrespo;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @all3ip;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sorthosize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @bothvalue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $oneval;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten_cat_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten_onlycat_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sorthousize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @toptensize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sortsize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @highsize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sortcat;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sortdowcatonly;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @diff_value;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @hourly_op;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topt_3;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @next3array;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $pages;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @special;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @next3soarray;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sortcatonly;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my $how;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten_hourly;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @highestsize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten_onlycat;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my %count;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sortcatsize;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @topten_cat;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @nextarray;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @nextsoarray;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @sortqwe;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @grephours ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my @timarr = (1 .. 24);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my ($begin_time, $end_time, $total_hits);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my ($Start_Hour,$Start_Min,$End_Hour,$End_Min);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my ($host, $ident_user, $auth_user, $date, $time, $time_zones, $farji, $farji2i, $farji3, $farji4, $farji5, $farji6, $farji7, $farji8, $farji9, $farji10, $farji11, $farji12) ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my ($hour, $min, $sec) ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Log File Used for Parsing is --&amp;gt;$Log_Path&quot;.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; open (MYFILE,$Log_Path) || die &quot;Error : $!&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ############### parse command line argument and choose the right request to server ############&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ARGV[1] =~ &quot;--Hourly&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time --&amp;gt;in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Start_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $Start_Min &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time --&amp;gt; in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($End_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $End_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $End_Min &amp;gt;= 0 &amp;amp;&amp;amp; $End_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;lt;= $End_Hour) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;This is Right Order Of Time Duration&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End_Hour should be greater than or equal to start hour. Give the right ordering&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour == 24){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Default Value of End Minute when End Hour is 24&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $End_Min = 00 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hourly_repso ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hourly_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--Default&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;genral_behav ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hou_only_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;download_wise;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;cat_only_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--CategoryWise&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Give Category you want to analyze &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Category = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Category Choosen --&amp;gt; &quot;.$Category.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;category_wise ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;categ_down_wise;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--Categ_Hourly&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time --&amp;gt;in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Start_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $Start_Min &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time --&amp;gt; in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($End_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $End_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $End_Min &amp;gt;= 0 &amp;amp;&amp;amp; $End_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;lt;= $End_Hour) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;This is Right Order Of Time Duration&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End_Hour should be greater than or equal to start hour. Give the right ordering&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour == 24){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Default Value of End Minute when End Hour is 24&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $End_Min = 00 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Give Category you want to analyze &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Category = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Category Choosen --&amp;gt; &quot;.$Category.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hourcateg_repso;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;download_wise;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hourly_cat_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--Download&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;download_wise ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;cat_only_size;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--Cat_Download&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Give Category you want to analyze &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Category = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Category Choosen --&amp;gt; &quot;.$Category.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;category_wise ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--Hourly_Download&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Analyze Hourly Download &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time --&amp;gt;in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Start_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $Start_Min &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time --&amp;gt; in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($End_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $End_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $End_Min &amp;gt;= 0 &amp;amp;&amp;amp; $End_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;lt;= $End_Hour) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;This is Right Order Of Time Duration&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End_Hour should be greater than or equal to start hour. Give the right ordering&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour == 24){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Default Value of End Minute when End Hour is 24&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $End_Min = 00 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;categ_down_wise;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hourly_size ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--Create_Hourly_Logs&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot; Analyze Category Wise Hourly Download &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time --&amp;gt;in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($Start_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $Start_Min &amp;gt;= 0 &amp;amp;&amp;amp; $Start_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $Start_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Start Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time of analysis Period &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time --&amp;gt; in format of HH:MM --&amp;gt; &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($End_Time_Dur = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour &amp;gt;= 0 &amp;amp;&amp;amp; $End_Hour &amp;lt;= 24 &amp;amp;&amp;amp; $End_Min &amp;gt;= 0 &amp;amp;&amp;amp; $End_Min &amp;lt;= 60) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Hour.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End Time Should be in range of 00 to 24 hours &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($Start_Hour &amp;lt;= $End_Hour) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;This is Right Order Of Time Duration&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;End_Hour should be greater than or equal to start hour. Give the right ordering&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($End_Hour == 24){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Default Value of End Minute when End Hour is 24&quot;.&quot;\n&quot; ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $End_Min = 00 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print $End_Min.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Give THe File Name To wirte the Logs--&amp;gt;&quot;.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chomp($output_file = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Output File Name is --&amp;gt; &quot;.$output_file.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #print &quot;Give Category you want to analyze &quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #chomp($Category = &amp;lt;STDIN&amp;gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #print &quot; Category Choosen --&amp;gt; &quot;.$Category.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;hourly_op ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elsif ($ARGV[1] =~ &quot;--All3Ip&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;new_all3_ip ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elsif ($ARGV[1] =~ &quot;--URL&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;uniqe_url;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;greedy_parse;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;parse_unique;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;elsif ($ARGV[1] =~ &quot;--HperIP&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;break_component;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;perIPhit;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ############### parsing of command line argument over ############&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/perl-coding.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-4627185832802169326</guid><pubDate>Sat, 23 Nov 2013 08:58:00 +0000</pubDate><atom:updated>2013-11-23T00:58:28.680-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Question&#39;s</category><category domain="http://www.blogger.com/atom/ns#">Sybase</category><category domain="http://www.blogger.com/atom/ns#">Sybase Top 10 Interview Questions</category><title>Sybase Interview Questions and Answers : Part 2</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Advantage of Stored Procedure?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
faster execution,reduce network traffic,Modular
programming,reduced operator eror,enforced consistency&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
can I update view?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
yes,but view had created using only one table than update is
possiable&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
explain about @@sqlstatus?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
It returns the status of the pervious fetch statement in a
cursor&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is the disadvantage of CURSOR?&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
Each time you fetch a row from the cursor, it results in a
network roundtrip, where as a normal SELECT query makes only one rowundtrip,
however large the resultset is. Cursors are also costly because they require
more resources and temporary storage (results in more IO operations). Furthere,
there are restrictions on the SELECT statements that can be used with some
types of cursors. Most of the times, set based operations can be used instead
of cursors.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What are the Properties of Transaction?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
server maintain transaction log,server locks table pages
during transaction,server performs automatic recovery upon restart ,transaction
control statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is lock escalation?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Lock escalation is the process of converting a lot of low
level locks (like row locks, page locks) into higher level locks (like table
locks).&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
How do I get the Duplicate rows from a table?&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
select * from table name group by column1 having
count(*)&amp;gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is Checkpoint?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The point at which all data pages that have been changed are
guaranteed to have been written to the database device.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is Distribution page?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
server keeps distribution information for each index on a
separate page in the datebase&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
How shall I simulate from level 0 to level 3 in Isolation?&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
using holdlock&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Compare Join and SubQuery in performance?&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
Generally Join queries consume more memory than sub query.
Sub query in turn involve intermediate table creation so affects performance,
because of high I/Os fetches need for processing. If the RAM memory is more,
then the Joins can be used instead of sub queries. Under memory constraints we
can go for sub queries. Sometimes sub queries are flattened to join to improve
the performance. Also making the outer query to compare inner query with equality
option can materialize the subquery.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is ceiling()?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Smallest integer greater than or equal to specified value&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is the stored procedure to view current lock and
processes respectively? &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
sp_lock and sp_who&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Compare IN and EXISTS?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
in allow duplicate values and sub query have oe
column,exists not allow duplicates and inner query can have multi columns&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is Rollback trigger in a Trigger?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
You can roll back triggers using either the rollback trigger
statement or the rollback transaction statement (if the trigger is fired as
part of a transaction). However, rollback trigger rolls back only the effect of
the trigger and the statement that caused the trigger to fire; rollback
transaction rolls back the entire transaction&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What happen when we delete the table using Trigger?&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The delete row will entered into the Deleted table inside
the trigger&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is the Drawbacks of Normalization?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: justify;&quot;&gt;
Although most successful databases are normalized to some
degree, there is one substantial drawback of a normalized database: reduced
database performance. The acceptance of reduced performance requires the
knowledge that when a query or transaction request is sent to the database,
there are factors involved, such as CPU usage, memory usage, and input/output
(I/O). To make a long story short, a normalized database requires much more
CPU, memory, and I/O to process transactions and database queries than does a
denormalized database. A normalized database must locate the requested tables
and then join the data from the tables to either get the requested information
or to process the desired data. A more in-depth discussion concerning database
performance occurs in Hour 18, &quot;Managing Database Users.&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/sybase-interview-questions-and-answers_23.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-5457072665224436464</guid><pubDate>Sat, 23 Nov 2013 08:56:00 +0000</pubDate><atom:updated>2013-11-23T00:56:48.032-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Question&#39;s</category><category domain="http://www.blogger.com/atom/ns#">Sybase</category><category domain="http://www.blogger.com/atom/ns#">Sybase Top 10 Interview Questions</category><title>Sybase Interview Questions and Answers : Part 1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
List out the limitation on stored procedures?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
SP may not create view,defaults,rules.trigger or procedures
,you can create table ,A table cannot be created,droppedor recreated with same
name in single procedure,Sp are reusable,recursive but not reentrant&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Tell me the limitation of the Trigger?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
any create commend,drop command,alter
table,grant,revoke,select into,truncate,update statistics are not permitted in
trigger&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
what is difference between constraints and rules?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
rules deals with constant and one rule can bound one
column,constraints can bound many column and it can be compare with column in
another table&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What are the steps involved in creating cursor? &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Declaring cursors,declaring variables,opening
cursors,fetching rows,main loop,closing the cursor,deallocating cursors&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is Demand lock and Dead lock?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
A deadlock occurs when there is a cyclic dependency between
two or more transactions for the same set of resources. Demand Lock:A demand
lock prevents any more shared locks from being set on a data resource (table or
data page). Any new shared lock request has to wait for the demand lock request
to finish.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What are the modes of transaction? And how do you change
from one mode to another?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
unchained mode: The default mode, called unchained or
Transact-SQL mode, requires explicit begin transaction statements paired with
commit transaction or rollback transaction statements to complete
the transaction. chained mode: The SQL standards-compatible mode, called
chained mode, implicitly begins a transaction before any data retrieval or modification statement. These statements include: delete,
insert,&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
open, fetch, select, and update. You must still explicitly
end the transaction with commit transaction or rollback transaction. You can set either mode using the chained option of the set
command.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
what is command permission and object permission?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
OP is Grant/revoke to these objects for permissions which
includes select,update,delete,execute.CP is grant /revoke permission for create
(db,table,view,procedure,defaults)&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is Index Covering?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Index covering is a mechanism for using the leaf level of
nonclustered index the way the data page of a clustered index would work. Index
covering occurs when all columns referenced in a query are contained in the
index itself.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is direct update and deffered update?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Direct Update:An update operation that takes place in a
single step, that is, the log records are written and the data and index pages
are changed. Direct updates can be performed in three ways: in-place update, on-page
update, and delete/insert direct update. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Deffered Update:An update operation that takes place in two
steps. First, the log records for deleting existing entries and inserting new
entries are written to the log, but only the delete changes to the data pages
and indexes take place. In the second step, the log pages are rescanned, and
the insert operations are performed on the data pages and indexes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
How will you minimizse the Lock contention?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
keep Transaction as short and concise as possiable,keep transaction
in single batch,consider running transaction in stored procedure,commit update
in cursor frequently,avoid hotspots.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
How will you find second maximum value in a table?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(column1) from table where
column1&amp;lt;(select max(column1) from table)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
what are different global variables ?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
@@tranchained-returns the current transcation mode.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
@@sqlstatus-status of previous fetch statement in cursor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Compare 2 nd and 3 rd Normal form?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Second normal form-nonkey fields must depend on the entire
pr. Key.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Third normal form---nonkey fields must not depend on other
nonkey fields.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is –I option in Sybase tools?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
It is the name of the interface file to use when trying to
find a server to connect to&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What is Phantom reads?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
when one transaction reads a set of rows that satisfy a
search condition, and then a second transaction modifies the data (through an insert,
delete, update, and so on). If the first transaction repeats the read with the
same search conditions, it obtains a different set of rows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Explain Denormalization techniques?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Denormalization is used for performance boosting. In which
normalized db is denormalized for the sake of performance. According to
normalization all columns has to depend on the primary key, but some times
creating a manipulated field.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Redundant column may be used in a table when we always join
the first table to get a column data from the second table using foreign key.
Data partitioning techniques like vertically splitting the tables, horizontally
splitting the tables can be used to denormalize a db. Vertical split technique
is typically used to minimize the size of the primary table or to move
infrequently accessed columns to a separate table. Horizontal split technique
involves splitting the table at row level into two or more tables. For ex, if
we can split the table into two tables, so that the first table has the recent
entries and a table that has historical data, we can drastically increase the
size of the new table, whose columns are going to access frequently&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/sybase-interview-questions-and-answers.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-2187541319506966657</guid><pubDate>Thu, 21 Nov 2013 17:41:00 +0000</pubDate><atom:updated>2013-11-21T09:41:55.272-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dot NET Framework</category><category domain="http://www.blogger.com/atom/ns#">Dot NET Interview Questions and Answers</category><category domain="http://www.blogger.com/atom/ns#">Job Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Bangalore</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Chennai</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Hyderabad</category><category domain="http://www.blogger.com/atom/ns#">Jobs in NCR</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Noida</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Pune</category><title>Dot NET Interview Questions Only - Part3</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;ul style=&quot;background-color: white; border: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 25px; margin: 0px 0px 0px 15px; outline: 0px; padding: 0px 0px 0px 15px; vertical-align: baseline; width: 650px;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is IL code, CLR, CTS, GAC &amp;amp; GC?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How can we do Assembly versioning?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;can you explain how ASP.NET application life cycle and page life cycle events fire?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is the problem with Functional Programming?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Can you define OOP and the 4 principles of OOP?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What are Classes and Objects?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is Inheritance?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is Polymorphism, overloading, overriding and virtual?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Can you explain encapsulation and abstraction?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is an abstract class?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Define Interface &amp;amp; What is the diff. between abstract &amp;amp; interface?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What problem does Delegate Solve ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is a Multicast delegate ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What are events and what&#39;s the difference between delegates and events?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How can we make Asynchronous method calls using delegates ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is a stack, Heap, Value types and Reference types ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is boxing and unboxing ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Can you explain ASP.NET application and Page life cycle ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;What is Authentication, Authorization, Principal &amp;amp; Identity objects?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How can we do Inproc and outProc session management ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How can we windows , forms and passport authentication and authorization in ASP.NET ?&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;In a parent child relationship which constructor fires first ?&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/dot-net-interview-questions-only-part3.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-8068523219997061376</guid><pubDate>Thu, 21 Nov 2013 17:40:00 +0000</pubDate><atom:updated>2013-11-21T09:40:30.877-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dot NET Framework</category><category domain="http://www.blogger.com/atom/ns#">Dot NET Interview Questions and Answers</category><category domain="http://www.blogger.com/atom/ns#">Engineering Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Job Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Delhi</category><category domain="http://www.blogger.com/atom/ns#">Jobs In gurgaon</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Hyderabad</category><category domain="http://www.blogger.com/atom/ns#">Jobs in NCR</category><category domain="http://www.blogger.com/atom/ns#">Jobs in Noida</category><title>Dot NET Interview Questions and Answers - Part2</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
How is .NET able to support multiple languages?&lt;br /&gt;
A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.&lt;br /&gt;
&lt;br /&gt;
How ASP .NET different from ASP?&lt;br /&gt;
Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.&lt;br /&gt;
&lt;br /&gt;
What is smart navigation?&lt;br /&gt;
The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.&lt;br /&gt;
&lt;br /&gt;
What is view state?&lt;br /&gt;
The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control&lt;br /&gt;
&lt;br /&gt;
How do you validate the controls in an ASP .NET page?&lt;br /&gt;
Using special validation controls that are meant for this. We have Range Validator, Email Validator.&lt;br /&gt;
&lt;br /&gt;
Can the validation be done in the server side? Or this can be done only in the Client side?&lt;br /&gt;
&lt;br /&gt;
Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.&lt;br /&gt;
&lt;br /&gt;
How to manage pagination in a page?&lt;br /&gt;
Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.&lt;br /&gt;
&lt;br /&gt;
What is ADO .NET and what is difference between ADO and ADO.NET?&lt;br /&gt;
ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/dot-net-interview-questions-and-answers_21.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-6792232122693613923</guid><pubDate>Thu, 21 Nov 2013 17:38:00 +0000</pubDate><atom:updated>2013-11-21T09:38:35.479-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dot NET Framework</category><category domain="http://www.blogger.com/atom/ns#">Dot NET Interview Questions and Answers</category><category domain="http://www.blogger.com/atom/ns#">Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Job Interview Questions</category><title>Dot NET Interview Questions and Answers - Part1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1. What is .NET Framework?&lt;br /&gt;
&lt;br /&gt;
.NET Framework is a complete environment that allows developers to develop, run, and deploy the following applications:&lt;br /&gt;
&lt;br /&gt;
Console applications&lt;br /&gt;
Windows Forms applications&lt;br /&gt;
Windows Presentation Foundation (WPF) applications&lt;br /&gt;
Web applications (ASP.NET applications)&lt;br /&gt;
Web services&lt;br /&gt;
Windows services&lt;br /&gt;
Service-oriented applications using Windows Communication Foundation (WCF)&lt;br /&gt;
Workflow-enabled applications using Windows Workflow Foundation (WF)&lt;br /&gt;
&lt;br /&gt;
.NET Framework also enables a developer to create sharable components to be used in distributed computing architecture. NET Framework supports the object-oriented programming model for multiple languages, such as Visual Basic, Visual C#, and Visual C++. .NET Framework supports multiple programming languages in a manner that allows language interoperability. This implies that each language can use the code written in some other language.&lt;br /&gt;
2. What are the main components of .NET Framework?&lt;br /&gt;
&lt;br /&gt;
.NET Framework provides enormous advantages to software developers in comparison to the advantages provided by other platforms. Microsoft has united various modern as well as existing technologies of software development in .NET Framework. These technologies are used by developers to develop highly efficient applications for modern as well as future business needs. The following are the key components of .NET Framework:&lt;br /&gt;
&lt;br /&gt;
.NET Framework Class Library&lt;br /&gt;
Common Language Runtime&lt;br /&gt;
Dynamic Language Runtimes (DLR)&lt;br /&gt;
Application Domains&lt;br /&gt;
Runtime Host&lt;br /&gt;
Common Type System&lt;br /&gt;
Metadata and Self-Describing Components&lt;br /&gt;
Cross-Language Interoperability&lt;br /&gt;
.NET Framework Security&lt;br /&gt;
Profiling&lt;br /&gt;
Side-by-Side Execution&lt;br /&gt;
3. List the new features added in .NET Framework 4.0.&lt;br /&gt;
&lt;br /&gt;
The following are the new features of .NET Framework 4.0:&lt;br /&gt;
&lt;br /&gt;
Improved Application Compatibility and Deployment Support&lt;br /&gt;
Dynamic Language Runtime&lt;br /&gt;
Managed Extensibility Framework&lt;br /&gt;
Parallel Programming framework&lt;br /&gt;
Improved Security Model&lt;br /&gt;
Networking Improvements&lt;br /&gt;
Improved Core ASP.NET Services&lt;br /&gt;
Improvements in WPF 4&lt;br /&gt;
Improved Entity Framework (EF)&lt;br /&gt;
Integration between WCF and WF&lt;br /&gt;
4. What is an IL?&lt;br /&gt;
&lt;br /&gt;
Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.&lt;br /&gt;
&lt;br /&gt;
5. What is Manifest?&lt;br /&gt;
&lt;br /&gt;
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things&lt;br /&gt;
Version of assembly.&lt;br /&gt;
Security identity.&lt;br /&gt;
Scope of the assembly.&lt;br /&gt;
Resolve references to resources and classes.&lt;br /&gt;
&lt;br /&gt;
The assembly manifest can be stored in a PE file either (an .exe or) .dll with Microsoft&lt;br /&gt;
intermediate language (MSIL code with Microsoft intermediate language (MSIL) code or in a&lt;br /&gt;
stand-alone PE file, that contains only assembly manifest information.&lt;br /&gt;
6. What are code contracts?&lt;br /&gt;
&lt;br /&gt;
Code contracts help you to express the code assumptions and statements stating the behavior of your code in a language-neutral way. The contracts are included in the form of pre-conditions, post-conditions and object-invariants. The contracts help you to improve-testing by enabling run-time checking, static contract verification, and documentation generation.&lt;br /&gt;
&lt;br /&gt;
The System.Diagnostics.Contracts namespace contains static classes that are used to express contracts in your code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/dot-net-interview-questions-and-answers.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-2248859888711169505</guid><pubDate>Mon, 18 Nov 2013 15:36:00 +0000</pubDate><atom:updated>2013-11-18T07:36:45.556-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">10 Core Java Interview Questions &amp; Answers for Senior Experienced Developer</category><category domain="http://www.blogger.com/atom/ns#">10 Tricky Java Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">15 Most Java Interview Questions for Experienced</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Questions of Java Strings</category><title>Top 10 Questions of Java Strings</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The following are top 10 frequently asked questions about Java Strings.&lt;br /&gt;
&lt;br /&gt;
1. How to compare strings? Use “==” or use equals()?&lt;br /&gt;
&lt;br /&gt;
In brief, “==” tests if references are equal and equals() tests if values are equal. Unless you want to check if two strings are the same object, you should always use equals().&lt;br /&gt;
&lt;br /&gt;
It would be better if you know the concept of string interning.&lt;br /&gt;
&lt;br /&gt;
2. Why is char[] preferred over String for security sensitive information?&lt;br /&gt;
&lt;br /&gt;
Strings are immutable, which means once they are created, they will stay unchanged until Garbage Collector kicks in. With an array, you can explicitly change its elements. In this way, security sensitive information(e.g. password) will not be present anywhere in the system.&lt;br /&gt;
&lt;br /&gt;
3. Can we use string for switch statement?&lt;br /&gt;
&lt;br /&gt;
Yes to version 7. From JDK 7, we can use string as switch condition. Before version 6, we can not use string as switch condition.&lt;br /&gt;
&lt;br /&gt;
view sourceprint?&lt;br /&gt;
01.&lt;br /&gt;
// java 7 only!&lt;br /&gt;
02.&lt;br /&gt;
switch (str.toLowerCase()) {&lt;br /&gt;
03.&lt;br /&gt;
case &quot;a&quot;:&lt;br /&gt;
04.&lt;br /&gt;
value = 1;&lt;br /&gt;
05.&lt;br /&gt;
break;&lt;br /&gt;
06.&lt;br /&gt;
case &quot;b&quot;:&lt;br /&gt;
07.&lt;br /&gt;
value = 2;&lt;br /&gt;
08.&lt;br /&gt;
break;&lt;br /&gt;
09.&lt;br /&gt;
}&lt;br /&gt;
4. How to convert string to int?&lt;br /&gt;
&lt;br /&gt;
view sourceprint?&lt;br /&gt;
1.&lt;br /&gt;
int n = Integer.parseInt(&quot;10&quot;);&lt;br /&gt;
Simple, but so frequently used and sometimes ignored.&lt;br /&gt;
&lt;br /&gt;
5. How to split a string with white space characters?&lt;br /&gt;
&lt;br /&gt;
We can simple do split using regular expression. “\s” stands for white space characters such as ” “, “\t”, “\r”, “\n”.&lt;br /&gt;
&lt;br /&gt;
view sourceprint?&lt;br /&gt;
1.&lt;br /&gt;
String[] strArray = aString.split(&quot;\\s+&quot;);&lt;br /&gt;
6. What substring() method does?&lt;br /&gt;
&lt;br /&gt;
In JDK 6, the substring() method gives a window to an array of chars which represents the existing String, but do not create a new one. To create a new array to back string, you can do add an empty string like the following:&lt;br /&gt;
view sourceprint?&lt;br /&gt;
1.&lt;br /&gt;
str.substring(m, n) + &quot;&quot;&lt;br /&gt;
This will create a new char array that represents the new string. The above approach sometimes can make your code faster, because Garbage Collector can collect the unused large string and keep only the sub string. &amp;nbsp;In Oracle JDK 7, substring() creates a new char array, not uses the existing one. Check out the diagram for showing substring() difference between JDK 6 and JDK 7.&lt;br /&gt;
7. String vs StringBuilder vs StringBuffer&lt;br /&gt;
&lt;br /&gt;
String vs StringBuilder: StringBuilder is mutable, which means you can modify it after its creation.&lt;br /&gt;
StringBuilder vs StringBuffer: StringBuffer is synchronized, which means it is thread-safe but slower than StringBuilder.&lt;br /&gt;
&lt;br /&gt;
8. How to repeat a string?&lt;br /&gt;
&lt;br /&gt;
In Python, we can just multiple a number to repeat a string. In Java, we can use the repeat() method of StringUtils from Apache Commons Lang package.&lt;br /&gt;
&lt;br /&gt;
view sourceprint?&lt;br /&gt;
1.&lt;br /&gt;
String str = &quot;abcd&quot;;&lt;br /&gt;
2.&lt;br /&gt;
String repeated = StringUtils.repeat(str,3);&lt;br /&gt;
3.&lt;br /&gt;
//abcdabcdabcd&lt;br /&gt;
9. How to convert string to date?&lt;br /&gt;
&lt;br /&gt;
view sourceprint?&lt;br /&gt;
1.&lt;br /&gt;
String str = &quot;Sep 17, 2013&quot;;&lt;br /&gt;
2.&lt;br /&gt;
Date date = new SimpleDateFormat(&quot;MMMM d, yy&quot;, Locale.ENGLISH).parse(str);&lt;br /&gt;
3.&lt;br /&gt;
System.out.println(date);&lt;br /&gt;
4.&lt;br /&gt;
//Tue Sep 17 00:00:00 EDT 2013&lt;br /&gt;
10. How to count # of occurrences of a character in a string?&lt;br /&gt;
&lt;br /&gt;
Use StringUtils from apache commons lang.&lt;br /&gt;
&lt;br /&gt;
view sourceprint?&lt;br /&gt;
1.&lt;br /&gt;
int n = StringUtils.countMatches(&quot;11112222&quot;, &quot;1&quot;);&lt;br /&gt;
2.&lt;br /&gt;
System.out.println(n);&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/top-10-questions-of-java-strings.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-9214424213887623281</guid><pubDate>Mon, 18 Nov 2013 15:33:00 +0000</pubDate><atom:updated>2013-11-18T07:33:50.699-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">10 Tricky Java Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">15 Most Java Interview Questions for Experienced</category><category domain="http://www.blogger.com/atom/ns#">Java Interview Questions</category><title>10 Java Exception and Error Interview Questions Answers</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1) What is Exception in Java?&lt;br /&gt;
This is always been first interview question on Exception and mostly asked on fresher level interviews. I haven&#39;t seen anybody asking about what is Exception in senior and experienced level interviews, but this is quite popular at entry level. In simple word Exception is Java’s way to convey both system and programming errors. In Java Exception feature is implemented by using class like Throwable, Exception, RuntimeException and keywords like throw, throws, try, catch and finally. All Exception are derived form Throwable class. Throwable further divides errors in too category one is java.lang.Exception and other is java.lang.Error. &amp;nbsp;java.lang.Error deals with system errors like java.lang.StackOverFlowError or Java.lang.OutOfMemoryError while Exception is mostly used to deal with programming mistakes, non availability of requested resource etc.&lt;br /&gt;
&lt;br /&gt;
2) What is difference between Checked and Unchecked Exception in Java ?&lt;br /&gt;
This is another popular Java Exception interview question appears in almost all level of Java interviews. Main difference between Checked and Unchecked Exception lies in there handling. Checked Exception requires to be handled at compile time using try, catch and finally keywords or else compiler will flag error. This is not a requirement for Unchecked Exceptions. Also all exceptions derived from java.lang.Exception classes are checked exception, exception those which extends RuntimeException, these are known as unchecked exception in Java. You can also check next article for more differences between Checked and Unchecked Exception.&lt;br /&gt;
&lt;br /&gt;
3) What is similarity between NullPointerException and ArrayIndexOutOfBoundException in Java?&lt;br /&gt;
This is Java Exception interview question was not very popular, but appears in various fresher level interviews, to see whether candidate is familiar with concept of checked and unchecked exception or not. By the way answer of this interview question is both of them are example of unchecked exception and derived form RuntimeException. This question also opens door for difference of array in Java and C programming language, as arrays in C are unbounded and never throw ArrayIndexOutOfBoundException.&lt;br /&gt;
&lt;br /&gt;
4) What best practices you follow while doing Exception handling in Java ?&lt;br /&gt;
This Exception interview question in Java is very popular while hiring senior java developer of Technical Lead. Since exception handling is crucial part of project design and good knowledge of this is desirable. There are lot of best practices, which can help to make your code robust and flexible at same time, here are few of them:&lt;br /&gt;
&lt;br /&gt;
1) Returning boolean instead of returning null to avoid NullPointerException at callers end. Since NPE is most infamous of all Java exceptions, there are lot of techniques and coding best practices to minimize NullPointerException. You can check that link for some specific examples.&lt;br /&gt;
&lt;br /&gt;
2) Non empty catch blocks. Empty catch blocks &amp;nbsp;are considered as one of the bad practices in Exception handling because they just ate Exception without any clue, at bare minimum print stack trace but you should do alternative operation which make sense or defined by requirements.&lt;br /&gt;
&lt;br /&gt;
3) Prefer Unchecked exception over checked until you have a very good reason of not to do so. it improves readability of&lt;br /&gt;
code by removing boiler plate exception handling code&lt;br /&gt;
.&lt;br /&gt;
4) Never let your database Exception flowing till client error. since most of application deal with database and SQLException is a checked Exception in Java you should consider handling any database related errors in DAO layer of your application and only returning alternative value or something meaningful RuntimeException which client can understand and take action.&lt;br /&gt;
&lt;br /&gt;
5) calling close() methods for connections, statements, and streams on finally block in Java.&lt;br /&gt;
&lt;br /&gt;
I have already shared lot of these in my post Top 10 Java exception handling best practices, you can also refer that for more knowledge on this topic.&lt;br /&gt;
&lt;br /&gt;
5) Why do you think Checked Exception exists in Java, since we can also convey error using RuntimeException ?&lt;br /&gt;
This is a controversial question and you need to be careful while answering this interview question. Though they will definitely like to hear your opinion, what they are mostly interested in convincing reason. One of the reason I see is that its a design decision, which is influenced by experience in programming language prior to Java e.g. C++. Most of checked exceptions are in java.io package, which make sense because if you request any system resource and its not available, than a robust program must be able to handle that situation gracefully. By declaring IOException as checked Exception, Java ensures that your provide that gracefully exception handling. Another possible reason could be to ensuring that system resources like file descriptors, which are limited in numbers, should be released as soon as you are done with that using catch or finally block. Effective Java book from Joshua Bloch has couple of items in this topic, which is again worth reading.&lt;br /&gt;
&lt;br /&gt;
6) What is difference between throw and throws keyword in Java?&lt;br /&gt;
One more Java Exception interview questions from beginners kitty. throw and throws keyword may look quite similar, especially if you are new to Java programming and haven&#39;t seen much of it. Though they are similar in terms that both are used in Exception handling, they are different on how and where they are used in code. throws keyword is used in method signature to declare which checked exception method can throw, you can also declare unchecked exception, but that is not mandatory by compiler. This signifies lot of things like method is not going to handle Exception instead its throwing it, if method throws checked Exception then caller should provide compile time exception handling etc. On the other hand throw keyword is actually used to throw any Exception. Syntactically you can throw any Throwable (i.e. Throwable or any class derived from Throwable) , throw &amp;nbsp;keyword transfers control of execution to caller so it can be used in place of return keyword. Most common example of using throw in place of return is throwing UnSupportedOperationException from an empty method as shown below :&lt;br /&gt;
&lt;br /&gt;
private static void show() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; throw new UnsupportedOperationException(&quot;Not yet implemented&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
See this article for more differences between these two keywords in Java.&lt;br /&gt;
&lt;br /&gt;
7) What is Exception chaining in Java?&lt;br /&gt;
Exception chaining is a popular exception handling concept in Java, where another exception is thrown in response of an exception and creating a chain of Exceptions. This technique mostly used to wrap a checked exception into an unchecked or RuntimeException. By the way if you are throwing new exception due to another exception then always include original exception so that handler code can access root cause by using methods like getCause() and initCause().&lt;br /&gt;
&lt;br /&gt;
8) Have you written your own custom Exception in Java? How do you do that?&lt;br /&gt;
Ofcourse most of us has written custom or business Exceptions like AccountNotFoundExcepiton. Main purpose of asking this Java Exception interview question is to find out how you use this feature. This can be used for sophisticated and precise exception handling with tweak involved in whether you would choose a checked or unchecked exception. By creating a specific exception for specific case, you also gives lot of options to caller to deal with them elegantly. I always prefer to have a precise exception than a general exception. Though creating lots of specific exceptions quickly increase number of classes in your project, maintaining a practical balance between specific and general exceptions are key to success.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9) What changes has been introduced in JDK7 related to Exception handling in Java ?&lt;br /&gt;
A relatively new and recent Exception interview question in Java. JDK7 has introduced two major feature which is related to Error and Exception handling, &amp;nbsp;one is ability to handle multiple exception in one catch block, popularly known as multi cache block and other is ARM blocks in Java 7 for automatic resource management, also known as try with resource. Both of these feature can certainly help to reduce boiler plate code required for handling checked exceptions in Java and significantly improves readability of code. Knowledge of this feature, not only helps to write better error and exception code in Java, but also helps to do well during interviews. I also recommend reading Java 7 Recipes book to get more insight on useful features introduced in Java 7, including these two.&lt;br /&gt;
&lt;br /&gt;
10) Have you faced OutOfMemoryError in Java? How did you solved that?&lt;br /&gt;
This Java Error interview questions is mostly asked on senior level Java interviews and here interviewer is interested on your approach to tackle dangerous OutOfMemoryError. Admit it we always face this error no matter which kind of project you are working so if you say no it doesn&#39;t go very well with interviewer. I suggest even if you are not familiar or not faced it in reality but have 3 to 4 years of experience in Java, be prepare for it. At the same time, this is also a chance to impress interviewer by showing your advanced technical knowledge related to finding memory leaks, profiling and debugging. I have noticed that these skills almost always creates a positive impression. You can also see my post on how to fix java.lang.OutOfMemoryError for more detail on this topic.&lt;br /&gt;
&lt;br /&gt;
11) Does code form finally executes if method returns before finally block or JVM exits ?&lt;br /&gt;
This Java exception interview question can also be asked in code format, where given a code with System.exit() in try block and something in finally block. It’s worth knowing that, finally block in Java executes even when return keyword is used in try block. Only time they don’t execute is when you call JVM to exit by executing System.exit(0)from try block in Java.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
12) What is difference in final, finalize and finally keyword in Java?&lt;br /&gt;
Another classic interview question in core Java, this was asked to one of my friend on his telephonic interview for core Java developer with Morgan Stanley. final and finally are keyword, while finalize is method. final keyword is very useful for creating ad Immutable class in Java By making a class final, we prevent it from being extended, similarly by making a method final, we prevent it from being overridden,. On the other hand, finalize() method is called &amp;nbsp;by garbage collector, before that object is collected, but this is not guaranteed by Java specification. finally keyword is the only one which is related to error and exception handling and you should always have finally block in production code for closing connection and resources. See here for more detailed answer of this question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
13) What is wrong with following code :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;public static void start() throws IOException, RuntimeException{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; throw new RuntimeException(&quot;Not able to Start&quot;);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;public static void main(String args[]) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; start();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } catch (Exception ex) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ex.printStackTrace();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } catch (RuntimeException re) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; re.printStackTrace();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This code will throw compiler error on line where RuntimeException &amp;nbsp;variable “re” is written on catch block. since Exception is super class of RuntimeException, all RuntimeException thrown by start() method will be captured by first catch block and code will never reach second catch block and that&#39;s the reason compiler will flag error as &amp;nbsp;“exception java.lang.RuntimeException has already been caught&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
14) What is wrong with following code in Java:&lt;br /&gt;
&lt;br /&gt;
public class SuperClass { &lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void start() throws IOException{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new IOException(&quot;Not able to open file&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class SubClass extends SuperClass{ &lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void start() throws Exception{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new Exception(&quot;Not able to start&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
In this code compiler will complain on sub class where start() method gets overridden. As per rules of method overriding in Java, an overridden method can not throw Checked Exception which is higher in hierarchy than original method. Since here start() is throwing IOException in super class, start() in sub class can only throw either IOException or any sub class of IOException but not super class of IOException e.g. Exception.&lt;br /&gt;
&lt;br /&gt;
15) What is wrong with following Java Exception code:&lt;br /&gt;
&lt;br /&gt;
public static void start(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp;System.out.println(&quot;Java Exception interivew question Answers for Programmers&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String args[]) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;try{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; start();&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}catch(IOException ioe){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ioe.printStackTrace();&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
In this Java Exception example code, compiler will complain on line where we are handling IOException, since IOException is a checked Exception and start() method doesn&#39;t throw IOException, so compiler will flag error as &quot;exception java.io.IOException is never thrown in body of corresponding try statement&quot;, but if you change IOException to Exception compiler error will disappear because Exception can be used to catch all RuntimeException which doesn&#39;t require declaration in throws clause. I like this little tricky Java Exception interview question because its not easy to figure out result by chaining IOException to Exception. You can also check Java Puzzlers by Joshua Bloch and Neil Gafter for some tricky questions based on Java Errors and Exceptions.&lt;br /&gt;
&lt;br /&gt;
These are some of Java Error and Exception interview questions, I have mostly seen in both fresher and experienced level of Java interviews. There are a lot more questions on Exception which I haven&#39;t included and if you think you have a good question missed out than let me know and I will make effort to include it on this list of java exceptions question and answers. One last question of Java Exception I am leaving for you guys is &quot;Why Java Exception considered to be better alternative of returning error codes&quot; , let me know what is your thought on this list of Java Exception interview questions and answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/10-java-exception-and-error-interview.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-2262012849112208927</guid><pubDate>Mon, 18 Nov 2013 15:31:00 +0000</pubDate><atom:updated>2013-11-18T07:31:43.270-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">15 Most Java Interview Questions for Experienced</category><category domain="http://www.blogger.com/atom/ns#">Java Interview Questions: 10 Common Questions</category><category domain="http://www.blogger.com/atom/ns#">Top 10 tricky Java interview questions and answers</category><title>Top 10 Tricky Java interview questions and Answers</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
What will happen if you call return statement or System.exit on try or catch block ? will finally block execute?&lt;br /&gt;
This is a very popular tricky Java question and its tricky because many programmer think that finally block always executed. This question challenge that concept by putting return statement in try or catch block or calling System.exit from try or catch block. Answer of this tricky question in Java is that finally block will execute even if you put return statement in try block or catch block but finally block won&#39;t run if you call System.exit form try or catch.&lt;br /&gt;
&lt;br /&gt;
Can you override private or static method in Java ?&lt;br /&gt;
Another popular Java tricky question, As I said method overriding is a good topic to ask trick questions in Java. &amp;nbsp;Anyway, you can not override private or static method in Java, if you create similar method with same return type and same method arguments that&#39;s called method hiding. See Can you override private method in Java or more details.&lt;br /&gt;
&lt;br /&gt;
Does Java support multiple inheritance ?&lt;br /&gt;
This is the trickiest question in Java, if C++ can support direct multiple inheritance than why not Java is the argument Interviewer often give. See Why multiple inheritance is not supported in Java to answer this tricky Java question.&lt;br /&gt;
&lt;br /&gt;
What will happen if we put a key object in a HashMap which is already there ?&lt;br /&gt;
This tricky Java questions is part of How HashMap works in Java, which is also a popular topic to create confusing and tricky question in Java. well if you put the same key again than it will replace the old mapping because HashMap doesn&#39;t allow duplicate keys. See How HashMap works in Java for more tricky Java questions from HashMap.&lt;br /&gt;
&lt;br /&gt;
If a method throws NullPointerException in super class, can we override it with a method which throws RuntimeException?&lt;br /&gt;
One more tricky Java questions from overloading and overriding concept. Answer is you can very well throw super class of RuntimeException in overridden method but you can not do same if its checked Exception. See Rules of method overriding in Java for more details.&lt;br /&gt;
&lt;br /&gt;
What is the issue with following implementation of compareTo() method in Java&lt;br /&gt;
&lt;br /&gt;
public int compareTo(Object o){&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Employee emp = (Employee) emp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return this.id - o.id;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
where id is an integer number ?&lt;br /&gt;
Well three is nothing wrong in this Java question until you guarantee that id is always positive. This Java question becomes tricky when you can not guaranteed id is positive or negative. If id is negative than subtraction may overflow and produce incorrect result. See How to override compareTo method in Java for complete answer of this Java tricky question for experienced programmer.&lt;br /&gt;
&lt;br /&gt;
How do you ensure that N thread can access N resources without deadlock&lt;br /&gt;
If you are not well versed in writing multi-threading code then this is real tricky question for you. This Java question can be tricky even for experienced and senior programmer, who are not really exposed to deadlock and race conditions. Key point here is order, if you acquire resources in a particular order and release resources in reverse order you can prevent deadlock. See how to avoid deadlock in Java for a sample code example.&lt;br /&gt;
&lt;br /&gt;
What is difference between CyclicBarrier and CountDownLatch in Java&lt;br /&gt;
Relatively newer Java tricky question, only been introduced form Java 5. Main difference between both of them is that you can reuse CyclicBarrier even if Barrier is broken but you can not reuse CountDownLatch in Java. See CyclicBarrier vs CountDownLatch in Java for more differences.&lt;br /&gt;
&lt;br /&gt;
What is difference between StringBuffer and StringBuilder in Java ?&lt;br /&gt;
Classic Java questions which some people thing tricky and some consider very easy. StringBuilder in Java is introduced in Java 5 and only difference between both of them is that Stringbuffer methods are synchronized while StringBuilder is non synchronized. See StringBuilder vs StringBuffer for more differences.&lt;br /&gt;
&lt;br /&gt;
Can you access non static variable in static context?&lt;br /&gt;
Another tricky Java question from Java fundamentals. No you can not access static variable in non static context in Java. Read why you can not access non-static variable from static method to learn more about this tricky Java questions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/top-10-tricky-java-interview-questions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-8651303910760542818</guid><pubDate>Mon, 18 Nov 2013 15:30:00 +0000</pubDate><atom:updated>2013-11-18T07:30:06.668-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">10 Tricky Java Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">15 Most Java Interview Questions for Experienced</category><category domain="http://www.blogger.com/atom/ns#">Java Interview Questions: 10 Common Questions</category><title>Java Interview Questions - Part 1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
1. What&#39;s the difference between an interface and an
abstract class?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
An abstract class is a class that is only partially
implemented by the programmer. It may contain one or more abstract methods. An
abstract method is simply a function definition that serves to tell the
programmer that the method must be implemented in a child class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
An interface is similar to an abstract class; indeed
interfaces occupy the same namespace as classes and abstract classes. For that
reason, you cannot define an interface with the same name as a class. An
interface is a fully abstract class; none of its methods are implemented and
instead of a class sub-classing from it, it is said to implement that
interface.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Abstract classes can have constants, members, method stubs
and defined methods, whereas interfaces can only have constants and methods
stubs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Methods and members of an abstract class can be defined with
any visibility, whereas all methods of an interface must be defined as public.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
When inheriting an abstract class, the child class must
define the abstract methods, whereas an interface can extend another interface
and methods don&#39;t have to be defined.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
A child class can only extend a single abstract (or any
other) class, whereas an interface can extend or a class can implement multiple
other interfaces.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
A child class can define abstract methods with the same or
less restrictive visibility, whereas a class implementing an interface must
define the methods with the exact same visibility.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
2.&amp;nbsp; When to use
abstract class or interface?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Interface is used when you only want to declare which
methods and members a class MUST have. Anyone implementing the interfaca will
have to declare and implement the methods listed by the interface.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If you also want to have a default implementation, use
abstract class. Any class extending the abstract class will have to implement
only its abstract methods and members, and will have some default
implementation of the other methods of the abstract class, which you may
override or not.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Finally, you can implement as many interfaces as you want,
but only extend one class (being it abstract or not). Keep that on mind before
choosing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Abstract class is an incomplete implementation of some
concept. This incomplete implementation may be different in different context.
Derived class implements the abstract class in its context.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Interface defines contract or standard. Implementation of
the interface has to follow the contract or standard. Interfaces are more used
to set these types of standards or contracts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
3.&amp;nbsp; What does the
Serializable interface do ?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The Serializable interface is just a marker. It means that
objects can be serialized, i.e. they can be represented as a bit string and
restored from that bit string. For example, both of your classes are
serializable because they can be represented as a bit string (or regular
string). On the other hand, a class that represents a file handle given out by
the operating system can not be serialized: As soon as the program is finished,
that handle is gone, and there is no way to get it back. Reopening the file by
file name is not guaranteed to work, since it may have been
deleted/moved/changed permissions in the meantime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Serializing objects that don&#39;t implement the Serializable
interface will result in a NotSerializableException being thrown.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
4. How you can force the garbage collection ? &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Garbage collection automatic process and can&#39;t be forced.
You could request it by calling System.gc(). JVM does not guarantee that GC
will be started immediately. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Garbage collection is one of the most important feature of
Java, Garbage collection is also called automatic memory management as JVM
automatically removes the unused variables/objects (value is null) from the
memory. User program can&#39;t directly free the object from memory, instead it is
the job of the garbage collector to automatically free the objects that are no
longer referenced by a program. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Every class inherits finalize() method from
java.lang.Object, the finalize() method is called by garbage collector when it
determines no more references to the object exists. In Java, it is good idea to
explicitly assign null into a variable when no more in use. I Java on calling
System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but
there is no guarantee when all the objects will garbage collected. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
5 . What is Synchronization in Java?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Synchronization is a process of controlling the access of
shared resources by the multiple threads in such a manner that only one thread
can access one resource at a time. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
In non synchronized multithreaded application, it is
possible for one thread to modify a shared object while another thread is in
the process of using or updating the object&#39;s value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
6.&amp;nbsp; What is memory
leak?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
A memory leak is where an unreferenced object that will
never be used again still hangs around in memory and doesnt get garbage collected.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
7. What is difference between stringbuffer and
stringbuilder?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The only difference between StringBuffer and StringBuilder
is that StringBuilder is unsynchronized whereas StringBuffer is synchronized.
So when the application needs to be run only in a single thread then it is
better to use StringBuilder. StringBuilder is more efficient than StringBuffer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Criteria to choose among StringBuffer and StringBuilder&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If your text can change and will only be accessed from a
single thread, use a StringBuilder because StringBuilder is unsynchronized.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If your text can changes, and will be accessed from multiple
threads, use a StringBuffer because StringBuffer is synchronous.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
8. What is the difference between checked and unchecked
exceptions?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
In general, unchecked exceptions represent defects in the
program (bugs), which are normally Runtime exceptions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Furthermore, checked exceptions represent invalid conditions
in areas outside the immediate control of the program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
9.&amp;nbsp; How does Java
allocate stack and heap memory?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;Each time an object
is created in Java it goes into the area of memory known as heap. The primitive
variables like int and double are allocated in the stack, if they are local
method variables and in the heap if they are member variables (i.e. fields of a
class). &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
In Java methods local variables are pushed into stack when a
method is invoked and stack pointer is decremented when a method call is
completed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
In a multi-threaded application each thread will have its
own stack but will share the same heap. This is why care should be taken in
your code to avoid any concurrent access issues in the heap space. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The stack is threadsafe (each thread will have its own
stack) but the heap is not threadsafe unless guarded with synchronisation
through your code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
10. What is Java Reflection?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Reflection is commonly used by programs which require the
ability to examine or modify the run time behavior of applications running in
the Java virtual machine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; vertical-align: baseline;&quot;&gt;



























































































&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/java-interview-questions-part-1.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-234144139419480697</guid><pubDate>Sat, 16 Nov 2013 19:38:00 +0000</pubDate><atom:updated>2013-11-16T11:38:03.296-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Perl For Interview</category><category domain="http://www.blogger.com/atom/ns#">Perl Frequently Asked Questions</category><category domain="http://www.blogger.com/atom/ns#">Perl Scripting</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Perl Interview Questions</category><title>Perl Most Ask Questions</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
What value is returned by a lone `return;&#39; statement?&lt;br /&gt;
The undefined value in scalar context, and the empty list value () in list context.&lt;br /&gt;
This way functions that wish to return failure can just use a simple return without worrying about the context in which they were called.&lt;br /&gt;
&lt;br /&gt;
What&#39;s the difference between /^Foo/s and /^Foo/?&lt;br /&gt;
The second would match Foo other than at the start of the record if $* were set.&lt;br /&gt;
The deprecated $* flag does double duty, filling the roles of both /s and /m. By using /s, you suppress any settings of that spooky variable, and force your carets and dollars to match only at the ends of the string and not at ends of line as well -- just as they would if $* weren&#39;t set at all.&lt;br /&gt;
&lt;br /&gt;
Does Perl have reference type?&lt;br /&gt;
Yes. Perl can make a scalar or hash type reference by using backslash operator.&lt;br /&gt;
For example&lt;br /&gt;
$str = &quot;here we go&quot;; # a scalar variable&lt;br /&gt;
$strref = \$str; # a reference to a scalar&lt;br /&gt;
&lt;br /&gt;
@array = (1..10); # an array&lt;br /&gt;
$arrayref = \@array; # a reference to an array&lt;br /&gt;
Note that the reference itself is a scalar.&lt;br /&gt;
&lt;br /&gt;
How to dereference a reference?&lt;br /&gt;
There are a number of ways to dereference a reference.&lt;br /&gt;
Using two dollar signs to dereference a scalar.&lt;br /&gt;
$original = $$strref;&lt;br /&gt;
Using @ sign to dereference an array.&lt;br /&gt;
@list = @$arrayref;&lt;br /&gt;
Similar for hashes.&lt;br /&gt;
&lt;br /&gt;
What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?&lt;br /&gt;
5&lt;br /&gt;
length() is a built-in prototyped as sub length($), and a scalar prototype silently changes aggregates into radically different forms. The scalar sense of a hash is false (0) if it&#39;s empty, otherwise it&#39;s a string representing the fullness of the buckets, like &quot;18/32&quot; or &quot;39/64&quot;. The length of that string is likely to be 5. Likewise, `length(@a)&#39; would be 2 if there were 37 elements in @a.&lt;br /&gt;
&lt;br /&gt;
If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{&quot;Foo::&quot;.EXPR}?&lt;br /&gt;
The second is disallowed under `use strict &quot;refs&quot;&#39;.&lt;br /&gt;
Dereferencing a string with *{&quot;STR&quot;} is disallowed under the refs stricture, although *{STR} would not be. This is similar in spirit to the way ${&quot;STR&quot;} is always the symbol table variable, while ${STR} may be the lexical variable. If it&#39;s not a bareword, you&#39;re playing with the symbol table in a particular dynamic fashion.&lt;br /&gt;
&lt;br /&gt;
How do I do &amp;lt; fill-in-the-blank &amp;gt; for each element in an array?&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
@homeRunHitters = (&#39;McGwire&#39;, &#39;Sosa&#39;, &#39;Maris&#39;, &#39;Ruth&#39;);&lt;br /&gt;
foreach (@homeRunHitters) {&lt;br /&gt;
print &quot;$_ hit a lot of home runs in one year\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
How do I replace every &amp;lt;TAB&amp;gt; character in a file with a comma?&lt;br /&gt;
&lt;br /&gt;
perl -pi.bak -e &#39;s/\t/,/g&#39; myfile.txt&lt;br /&gt;
&lt;br /&gt;
What is the easiest way to download the contents of a URL with Perl?&lt;br /&gt;
&lt;br /&gt;
Once you have the libwww-perl library, LWP.pm installed, the code is this:&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
use LWP::Simple;&lt;br /&gt;
$url = get &#39;http://www.websitename.com/&#39;;&lt;br /&gt;
&lt;br /&gt;
How to concatenate strings with Perl?&lt;br /&gt;
&lt;br /&gt;
Method #1 - using Perl&#39;s dot operator:&lt;br /&gt;
$name = &#39;checkbook&#39;;&lt;br /&gt;
$filename = &quot;/tmp/&quot; . $name . &quot;.tmp&quot;;&lt;br /&gt;
&lt;br /&gt;
Method #2 - using Perl&#39;s join function&lt;br /&gt;
$name = &quot;checkbook&quot;;&lt;br /&gt;
$filename = join &quot;&quot;, &quot;/tmp/&quot;, $name, &quot;.tmp&quot;;&lt;br /&gt;
&lt;br /&gt;
Method #3 - usual way of concatenating strings&lt;br /&gt;
$filename = &quot;/tmp/${name}.tmp&quot;;&lt;br /&gt;
&lt;br /&gt;
How do I read command-line arguments with Perl?&lt;br /&gt;
&lt;br /&gt;
With Perl, command-line arguments are stored in the array named @ARGV.&lt;br /&gt;
$ARGV[0] contains the first argument, $ARGV[1] contains the second argument, etc.&lt;br /&gt;
$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1.&lt;br /&gt;
Here&#39;s a simple program:&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
$numArgs = $#ARGV + 1;&lt;br /&gt;
print &quot;thanks, you gave me $numArgs command-line arguments.\n&quot;;&lt;br /&gt;
foreach $argnum (0 .. $#ARGV) {&lt;br /&gt;
print &quot;$ARGV[$argnum]\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When would `local $_&#39; in a function ruin your day?&lt;br /&gt;
When your caller was in the middle for a while(m//g) loop&lt;br /&gt;
The /g state on a global variable is not protected by running local on it. That&#39;ll teach you to stop using locals. Too bad $_ can&#39;t be the target of a my() -- yet.&lt;br /&gt;
&lt;br /&gt;
What happens to objects lost in &quot;unreachable&quot; memory, such as the object returned by Ob-&amp;gt;new() in `{ my $ap; $ap = [ Ob-&amp;gt;new(), \$ap ]; }&#39; ?&lt;br /&gt;
Their destructors are called when that interpreter thread shuts down.&lt;br /&gt;
When the interpreter exits, it first does an exhaustive search looking for anything that it allocated. This allows Perl to be used in embedded and multithreaded applications safely, and furthermore guarantees correctness of object code.&lt;br /&gt;
&lt;br /&gt;
Assume that $ref refers to a scalar, an array, a hash or to some nested data structure. Explain the following statements:&lt;br /&gt;
$$ref; # returns a scalar&lt;br /&gt;
$$ref[0]; # returns the first element of that array&lt;br /&gt;
$ref- &amp;gt; [0]; # returns the first element of that array&lt;br /&gt;
@$ref; # returns the contents of that array, or number of elements, in scalar context&lt;br /&gt;
$&amp;amp;$ref; # returns the last index in that array&lt;br /&gt;
$ref- &amp;gt; [0][5]; # returns the sixth element in the first row&lt;br /&gt;
@{$ref- &amp;gt; {key}} # returns the contents of the array that is the value of the key &quot;key&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How do you match one letter in the current locale?&lt;br /&gt;
/[^\W_\d]/&lt;br /&gt;
We don&#39;t have full POSIX regexps, so you can&#39;t get at the isalpha() &amp;lt;ctype.h&amp;gt; macro save indirectly. You ask for one byte which is neither a non-alphanumunder, nor an under, nor a numeric. That leaves just the alphas, which is what you want.&lt;br /&gt;
&lt;br /&gt;
How do I print the entire contents of an array with Perl?&lt;br /&gt;
To answer this question, we first need a sample array. Let&#39;s assume that you have an array that contains the name of baseball teams, like this:&lt;br /&gt;
@teams = (&#39;cubs&#39;, &#39;reds&#39;, &#39;yankees&#39;, &#39;dodgers&#39;);&lt;br /&gt;
If you just want to print the array with the array members separated by blank spaces, you can just print the array like this:&lt;br /&gt;
@teams = (&#39;cubs&#39;, &#39;reds&#39;, &#39;yankees&#39;, &#39;dodgers&#39;);&lt;br /&gt;
print &quot;@teams\n&quot;;&lt;br /&gt;
But that&#39;s not usually the case. More often, you want each element printed on a separate line. To achieve this, you can use this code:&lt;br /&gt;
@teams = (&#39;cubs&#39;, &#39;reds&#39;, &#39;yankees&#39;, &#39;dodgers&#39;);&lt;br /&gt;
foreach (@teams) {&lt;br /&gt;
print &quot;$_\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Perl uses single or double quotes to surround a zero or more characters. Are the single(&#39; &#39;) or double quotes (&quot; &quot;) identical?&lt;br /&gt;
They are not identical. There are several differences between using single quotes and double quotes for strings.&lt;br /&gt;
1. The double-quoted string will perform variable interpolation on its contents. That is, any variable references inside the quotes will be replaced by the actual values.&lt;br /&gt;
2. The single-quoted string will print just like it is. It doesn&#39;t care the dollar signs.&lt;br /&gt;
3. The double-quoted string can contain the escape characters like newline, tab, carraige return, etc.&lt;br /&gt;
4. The single-quoted string can contain the escape sequences, like single quote, backward slash, etc.&lt;br /&gt;
&lt;br /&gt;
How many ways can we express string in Perl?&lt;br /&gt;
Many. For example &#39;this is a string&#39; can be expressed in:&lt;br /&gt;
&quot;this is a string&quot;&lt;br /&gt;
qq/this is a string like double-quoted string/&lt;br /&gt;
qq^this is a string like double-quoted string^&lt;br /&gt;
q/this is a string/&lt;br /&gt;
q&amp;amp;this is a string&amp;amp;&lt;br /&gt;
q(this is a string)&lt;br /&gt;
&lt;br /&gt;
How do you give functions private variables that retain their values between calls?&lt;br /&gt;
Create a scope surrounding that sub that contains lexicals.&lt;br /&gt;
Only lexical variables are truly private, and they will persist even when their block exits if something still cares about them. Thus:&lt;br /&gt;
{ my $i = 0; sub next_i { $i++ } sub last_i { --$i } }&lt;br /&gt;
creates two functions that share a private variable. The $i variable will not be deallocated when its block goes away because next_i and last_i need to be able to access it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------------------------------------&lt;br /&gt;
&lt;br /&gt;
1) What are the two different types of data perl handles?&lt;br /&gt;
Perl handles two types of data they are&lt;br /&gt;
(i) Scalar Variables and&lt;br /&gt;
(ii) Lists&lt;br /&gt;
Scalar variables hold a single data item whereas lists hold multiple data items.&lt;br /&gt;
&lt;br /&gt;
2) What are scalar variables?&lt;br /&gt;
Scalar variables are what many programming languages refer to as simple variables. They hold a single data item, a number, a string, or a perl reference. Scalars are called scalars to differentiate them from constructs that can hold more than one item, like arrays.&lt;br /&gt;
&lt;br /&gt;
3) Explain about lists?&lt;br /&gt;
A list is a construct that associates data elements together and you can specify a list by enclosing those elements in parenthesis and separating them with commas. They could themselves be arrays, hashes or even other lists. Lists do not have a specific list data type.&lt;br /&gt;
&lt;br /&gt;
4) Name all the prefix dereferencer in perl?&lt;br /&gt;
The symbol that starts all scalar variables is called a prefix dereferencer. The different types of dereferencer are.&lt;br /&gt;
(i) $-Scalar variables&lt;br /&gt;
(ii) %-Hash variables&lt;br /&gt;
(iii) @-arrays&lt;br /&gt;
(iv) &amp;amp;-subroutines&lt;br /&gt;
(v) Type globs-*myvar stands for @myvar, %myvar.&lt;br /&gt;
5) Explain about an ivalue?&lt;br /&gt;
An ivalue is an item that can serve as the target of an assignment. The term I value originally meant a “left value”, which is to say a value that appears on the left. An ivalue usually represents a data space in memory and you can store data using the ivalues name. Any variable can serve as an ivalue.&lt;br /&gt;
6) How does a “grep” function perform?&lt;br /&gt;
Grep returns the number of lines the expression is true. Grep returns a sublist of a list for which a specific criterion is true. This function often involves pattern matching. It modifies the elements in the original list.&lt;br /&gt;
7) Explain about Typeglobs?&lt;br /&gt;
Type globs are another integral type in perl. A typeglob`s prefix derefrencer is *, which is also the wild card character because you can use typeglobs to create an alias for all types associated with a particular name. All kinds of manipulations are possible with typeglobs.&lt;br /&gt;
8) Is there any way to add two arrays together?&lt;br /&gt;
Of course you can add two arrays together by using push function. The push function adds a value or values to the end of an array. The push function pushes the values of list onto the end of the array. Length of an array can be increased by the length of list.&lt;br /&gt;
9) How to use the command shift?&lt;br /&gt;
Shift array function shifts off the first value of the array and returns it, thereby shortening the array by one element and moving everything from one place to the left. If you don’t specify an array to shift, shift uses @ ARGV, the array of command line arguments passed to the script or the array named @-.&lt;br /&gt;
10) What exactly is grooving and shortening of the array?&lt;br /&gt;
You can change the number of elements in an array simply by changing the value of the last index of/in the array $#array. In fact, if you simply refer to a non existent element in an array perl extends the array as needed, creating new elements. It also includes new elements in its array.&lt;br /&gt;
11) What are the three ways to empty an array?&lt;br /&gt;
The three different ways to empty an array are as follows&lt;br /&gt;
1) You can empty an array by setting its length to a negative number.&lt;br /&gt;
2) Another way of empting an array is to assign the null list ().&lt;br /&gt;
3) Try to clear an array by setting it to undef, but be aware when you set to undef.&lt;br /&gt;
&lt;br /&gt;
12) How do you work with array slices&lt;br /&gt;
An array slice is a section of an array that acts like a list, and you indicate what elements to put into the slice by using multiple array indexes in square brackets. By specifying the range operator you can also specify a slice.&lt;br /&gt;
13) What is meant by splicing arrays explain in context of list and scalar.&lt;br /&gt;
Splicing an array means adding elements from a list to that array, possibly replacing elements now in the array. In list context, the splice function returns the elements removed from the array. In scalar context, the splice function returns the last element removed.&lt;br /&gt;
14) What are the different types of perl operators?&lt;br /&gt;
There are four different types of perl operators they are&lt;br /&gt;
(i) Unary operator like the not operator&lt;br /&gt;
(ii) Binary operator like the addition operator&lt;br /&gt;
(iii) Tertiary operator like the conditional operator&lt;br /&gt;
(iv) List operator like the print operator&lt;br /&gt;
15) Which has the highest precedence, List or Terms? Explain?&lt;br /&gt;
Terms have the highest precedence in perl. Terms include variables, quotes, expressions in parenthesis etc. List operators have the same level of precedence as terms. Specifically, these operators have very strong left word precedence.&lt;br /&gt;
16) What is a short circuit operator?&lt;br /&gt;
The C-Style operator, ll, performs a logical (or) operation and you can use it to tie logical clauses together, returning an overall value of true if either clause is true. This operator is called a short-circuit operator because if the left operand is true the right operand is not checked or evaluated.&lt;br /&gt;
&lt;br /&gt;
17) What are the different forms of goto in perl? Explain?&lt;br /&gt;
The three forms of goto are as follows. They are&lt;br /&gt;
(i) Goto label&lt;br /&gt;
(ii) Goto name&lt;br /&gt;
(iii) Goto expr&lt;br /&gt;
The first form, goto LABEL, transfers execution to the statement labeled LABEL. The second form, goto EXPR, expects EXPR to evaluate to a label. The last form goto &amp;amp;name is used with subroutines. This goto statement is used only when there is a necessity as it can create havoc in a program.&lt;br /&gt;
18) What are the different types of eval statements?&lt;br /&gt;
There are two different types of eval statements they are eval EXPR and eval BLOCK. Eval EXPR executes an expression and eval BLOCK executes BLOCK. Eval Block executes an entire block, BLOCK. First one is used when you want your code passed in the expression and the second one is used to parse the code in the block.&lt;br /&gt;
19) Determine the difference between my and local?&lt;br /&gt;
The fundamental difference between my and local is that my creates a new variable, whereas local saves a copy of an existing variable.&lt;br /&gt;
20) Explain about returning values from subroutines (functions)?&lt;br /&gt;
The return value of the subroutine is the value of the last expression evaluated or you can explicitly use a return statement to exit the subroutine specifying the return value. That return value is evaluated in the appropriate content depending on the content of the subroutine call.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;1. Does Perl have reference type?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;2. How do I do &amp;lt; fill-in-the-blank &amp;gt; for each element in a hash?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;3. How do I do &amp;lt; fill-in-the-blank &amp;gt; for each element in an array?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;4. How do I do fill_in_the_blank for each file in a directory?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;5. How do I generate a list of all .html files in a directory?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;6. How do I print the entire contents of an array with Perl?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; -- Useful EBooks --&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; How To Naturally Regrow Lost Hair&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;7. How do I read command-line arguments with Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;8. How do I replace every character in a file with a comma?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;9. How do I send e-mail from a Perl/CGI program on a Unix system?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 10. How do I set environment variables in Perl programs?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 11. How do I sort a hash by the hash key?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 12. How do I sort a hash by the hash value?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 13. How do you find the length of an array?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 14. How do you give functions private variables that retain their values between calls?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 15. How do you match one letter in the current locale?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; -- Useful EBooks --&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Weird Tricks to Lose Your Abdominal Fat&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 16. How do you print out the next line from a filehandle with all its bytes reversed?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 17. How many ways can we express string in Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 18. How to concatenate strings with Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 19. How to dereference a reference?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 20. How to open and read data files with Perl&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 21. How to read file into hash array ?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 22. How to read from a pipeline with Perl&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 23. How to turn on Perl warnings? Why is that important?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 24. If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{&quot;Foo::&quot;.EXPR}?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 25. Perl uses single or double quotes to surround a zero or more characters. Are the single(&#39; &#39;) or double quotes (&quot; &quot;) identical?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 26. What are scalar data and scalar variables?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 27. What does Perl do if you try to exploit the execve(2) race involving setuid scripts?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 28. What does `$result = f() .. g()&#39; really return?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 29. What does `new $cur-&amp;gt;{LINK}&#39; do? (Assume the current package has no new() function of its own.)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 30. What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 31. What does read() return at end of file?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 32. What happens to objects lost in &quot;unreachable&quot; memory..... ?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 33. What happens when you return a reference to a private variable?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 34. What is the easiest way to download the contents of a URL with Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 35. What value is returned by a lone `return;&#39; statement?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 36. What&#39;s the difference between /^Foo/s and /^Foo/?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 37. When would `local $_&#39; in a function ruin your day?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 38. Which of these is a difference between C++ and Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 39. Why aren&#39;t Perl&#39;s patterns regular expressions?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 40. Why do you use Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 41. Why does Perl not have overloaded functions?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 42. Why is it hard to call this function: sub y { &quot;because&quot; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 43. Why should I use the -w argument with my Perl programs?&lt;br /&gt;
&lt;br /&gt;
-----------------------&lt;br /&gt;
&lt;br /&gt;
Question #2: Write a regular expression which matches a email address&lt;br /&gt;
&lt;br /&gt;
Answer: This is very tricky question. Matching emails is not as trivial as it seems and the answer can be as simple as \w+@\w+\.[\w]{3} &amp;nbsp;or as messy as ^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}&lt;br /&gt;
&lt;br /&gt;
Remember, it is interview question, not production code. So, be simple. I always recommend starting with basics:&lt;br /&gt;
\w+@\w+\.[\w]{3}&lt;br /&gt;
&lt;br /&gt;
Then explain its limitations and give couple examples there the pattern would give false positive or false negative results. (such as test@test.111). From my experience, usually it is more than enough to impress interviewer. &amp;nbsp;From the other side, you always can iteratively enhance this pattern engaging interviewer into the conversation giving you the chance to showcase your knowledge.oo/?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 37. When would `local $_&#39; in a function ruin your day?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 38. Which of these is a difference between C++ and Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 39. Why aren&#39;t Perl&#39;s patterns regular expressions?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 40. Why do you use Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 41. Why does Perl not have overloaded functions?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 42. Why is it hard to call this function: sub y { &quot;because&quot; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 43. Why should I use the -w argument with my Perl programs?&lt;br /&gt;
&lt;br /&gt;
-----------------------&lt;br /&gt;
&lt;br /&gt;
Question #2: Write a regular expression which matches a email address&lt;br /&gt;
&lt;br /&gt;
Answer: This is very tricky question. Matching emails is not as trivial as it seems and the answer can be as simple as \w+@\w+\.[\w]{3} &amp;nbsp;or as messy as ^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}&lt;br /&gt;
&lt;br /&gt;
Remember, it is interview question, not production code. So, be simple. I always recommend starting with basics:&lt;br /&gt;
\w+@\w+\.[\w]{3}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then explain its limitations and give couple examples there the pattern would give false positive or false negative results. (such as test@test.111). From my experience, usually it is more than enough to impress interviewer. &amp;nbsp;From the other side, you always can iteratively enhance this pattern engaging interviewer into the conversation giving you the chance to showcase your knowledge.&amp;nbsp;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/perl-most-ask-questions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-5229842730207968185</guid><pubDate>Sat, 16 Nov 2013 19:37:00 +0000</pubDate><atom:updated>2013-11-16T11:37:12.706-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Perl</category><category domain="http://www.blogger.com/atom/ns#">Perl For Interview</category><category domain="http://www.blogger.com/atom/ns#">Perl Frequently Asked Questions</category><category domain="http://www.blogger.com/atom/ns#">Perl Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Perl Interview Questions</category><title>Perl Frequently Asked Questions </title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;1. Does Perl have reference type?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;2. How do I do &amp;lt; fill-in-the-blank &amp;gt; for each element in a hash?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;3. How do I do &amp;lt; fill-in-the-blank &amp;gt; for each element in an array?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;4. How do I do fill_in_the_blank for each file in a directory?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;5. How do I generate a list of all .html files in a directory?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;6. How do I print the entire contents of an array with Perl?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; -- Useful EBooks --&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; How To Naturally Regrow Lost Hair&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;7. How do I read command-line arguments with Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;8. How do I replace every character in a file with a comma?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;9. How do I send e-mail from a Perl/CGI program on a Unix system?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 10. How do I set environment variables in Perl programs?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 11. How do I sort a hash by the hash key?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 12. How do I sort a hash by the hash value?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 13. How do you find the length of an array?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 14. How do you give functions private variables that retain their values between calls?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 15. How do you match one letter in the current locale?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; -- Useful EBooks --&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Weird Tricks to Lose Your Abdominal Fat&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 16. How do you print out the next line from a filehandle with all its bytes reversed?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 17. How many ways can we express string in Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 18. How to concatenate strings with Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 19. How to dereference a reference?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 20. How to open and read data files with Perl&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 21. How to read file into hash array ?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 22. How to read from a pipeline with Perl&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 23. How to turn on Perl warnings? Why is that important?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 24. If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{&quot;Foo::&quot;.EXPR}?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 25. Perl uses single or double quotes to surround a zero or more characters. Are the single(&#39; &#39;) or double quotes (&quot; &quot;) identical?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 26. What are scalar data and scalar variables?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 27. What does Perl do if you try to exploit the execve(2) race involving setuid scripts?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 28. What does `$result = f() .. g()&#39; really return?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 29. What does `new $cur-&amp;gt;{LINK}&#39; do? (Assume the current package has no new() function of its own.)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 30. What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 31. What does read() return at end of file?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 32. What happens to objects lost in &quot;unreachable&quot; memory..... ?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 33. What happens when you return a reference to a private variable?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 34. What is the easiest way to download the contents of a URL with Perl?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 35. What value is returned by a lone `return;&#39; statement?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 36. What&#39;s the difference between /^Foo/s and /^FPerl Interview Questions and Answers&lt;br /&gt;
&lt;br /&gt;
Why do you use Perl?&lt;br /&gt;
Perl is a powerful free interpreter.&lt;br /&gt;
Perl is portable, flexible and easy to learn.&lt;br /&gt;
&lt;br /&gt;
How do I set environment variables in Perl programs?&lt;br /&gt;
you can just do something like this:&lt;br /&gt;
$path = $ENV{&#39;PATH&#39;};&lt;br /&gt;
As you may remember, &quot;%ENV&quot; is a special hash in Perl that contains the value of all your environment variables.&lt;br /&gt;
Because %ENV is a hash, you can set environment variables just as you&#39;d set the value of any Perl hash variable. Here&#39;s how you can set your PATH variable to make sure the following four directories are in your path::&lt;br /&gt;
$ENV{&#39;PATH&#39;} = &#39;/bin:/usr/bin:/usr/local/bin:/home/yourname/bin&#39;;&lt;br /&gt;
&lt;br /&gt;
Which of these is a difference between C++ and Perl?&lt;br /&gt;
Perl can have objects whose data cannot be accessed outside its class, but C++ cannot.&lt;br /&gt;
Perl can use closures with unreachable private data as objects, and C++ doesn&#39;t support closures. Furthermore, C++ does support pointer arithmetic via `int *ip = (int*)&amp;amp;object&#39;, allowing you do look all over the object. Perl doesn&#39;t have pointer arithmetic. It also doesn&#39;t allow `#define private public&#39; to change access rights to foreign objects. On the other hand, once you start poking around in /dev/mem, no one is safe.&lt;br /&gt;
&lt;br /&gt;
How to open and read data files with Perl&lt;br /&gt;
Data files are opened in Perl using the open() function. When you open a data file, all you have to do is specify (a) a file handle and (b) the name of the file you want to read from.&lt;br /&gt;
As an example, suppose you need to read some data from a file named &quot;checkbook.txt&quot;. Here&#39;s a simple open statement that opens the checkbook file for read access: open (CHECKBOOK, &quot;checkbook.txt&quot;); In this example, the name &quot;CHECKBOOK&quot; is the file handle that you&#39;ll use later when reading from the checkbook.txt data file. Any time you want to read data from the checkbook file, just use the file handle named &quot;CHECKBOOK&quot;.&lt;br /&gt;
Now that we&#39;ve opened the checkbook file, we&#39;d like to be able to read what&#39;s in it. Here&#39;s how to read one line of data from the checkbook file:&lt;br /&gt;
$record = &amp;lt; CHECKBOOK &amp;gt; ;&lt;br /&gt;
After this statement is executed, the variable $record contains the contents of the first line of the checkbook file. The &quot;&amp;lt;&amp;gt;&quot; symbol is called the line reading operator.&lt;br /&gt;
To print every record of information from the checkbook file&lt;br /&gt;
&lt;br /&gt;
open (CHECKBOOK, &quot;checkbook.txt&quot;) || die &quot;couldn&#39;t open the file!&quot;;&lt;br /&gt;
while ($record = &amp;lt; CHECKBOOK &amp;gt;) {&lt;br /&gt;
print $record;&lt;br /&gt;
}&lt;br /&gt;
close(CHECKBOOK);&lt;br /&gt;
&lt;br /&gt;
How do I do fill_in_the_blank for each file in a directory?&lt;br /&gt;
Here&#39;s code that just prints a listing of every file in the current directory:&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
opendir(DIR, &quot;.&quot;);&lt;br /&gt;
@files = readdir(DIR);&lt;br /&gt;
closedir(DIR);&lt;br /&gt;
foreach $file (@files) {&lt;br /&gt;
print &quot;$file\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
How do I do fill_in_the_blank for each file in a directory?&lt;br /&gt;
&lt;br /&gt;
Here&#39;s code that just prints a listing of every file in the current directory:&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
opendir(DIR, &quot;.&quot;);&lt;br /&gt;
@files = readdir(DIR);&lt;br /&gt;
closedir(DIR);&lt;br /&gt;
foreach $file (@files) {&lt;br /&gt;
print &quot;$file\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
How do I generate a list of all .html files in a directory?&lt;br /&gt;
Here&#39;s a snippet of code that just prints a listing of every file in the current directory that ends with the extension .html:&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
opendir(DIR, &quot;.&quot;);&lt;br /&gt;
@files = grep(/\.html$/,readdir(DIR));&lt;br /&gt;
closedir(DIR);&lt;br /&gt;
foreach $file (@files) {&lt;br /&gt;
print &quot;$file\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
What is Perl one-liner?&lt;br /&gt;
There are two ways a Perl script can be run:&lt;br /&gt;
--from a command line, called one-liner, that means you type and execute immediately on the command line. You&#39;ll need the -e option to start like &quot;C:\ %gt perl -e &quot;print \&quot;Hello\&quot;;&quot;. One-liner doesn&#39;t mean one Perl statement. One-liner may contain many statements in one line.&lt;br /&gt;
--from a script file, called Perl program.&lt;br /&gt;
&lt;br /&gt;
Assuming both a local($var) and a my($var) exist, what&#39;s the difference between ${var} and ${&quot;var&quot;}?&lt;br /&gt;
${var} is the lexical variable $var, and ${&quot;var&quot;} is the dynamic variable $var.&lt;br /&gt;
Note that because the second is a symbol table lookup, it is disallowed under `use strict &quot;refs&quot;&#39;. The words global, local, package, symbol table, and dynamic all refer to the kind of variables that local() affects, whereas the other sort, those governed by my(), are variously knows as private, lexical, or scoped variable.&lt;br /&gt;
&lt;br /&gt;
What happens when you return a reference to a private variable?&lt;br /&gt;
Perl keeps track of your variables, whether dynamic or otherwise, and doesn&#39;t free things before you&#39;re done using them.&lt;br /&gt;
&lt;br /&gt;
How to turn on Perl warnings? Why is that important?&lt;br /&gt;
Perl is very forgiving of strange and sometimes wrong code, which can mean hours spent searching for bugs and weird results. Turning on warnings helps uncover common mistakes and strange places and save a lot of debugging time in the long run. There are various ways of turning on Perl warnings:&lt;br /&gt;
For Perl one-liner, use -w option on the command line.&lt;br /&gt;
On Unix or Windows, use the -w option in the shebang line (The first # line in the script). Note: Windows Perl interpreter may not require it.&lt;br /&gt;
For other systems, choose compiler warnings, or check compiler documentation.&lt;br /&gt;
&lt;br /&gt;
What are scalar data and scalar variables?&lt;br /&gt;
Perl has a flexible concept of data types. Scalar means a single thing, like a number or string. So the Java concept of int, float, double and string equals to Perl\&#39;s scalar in concept and the numbers and strings are exchangeable. Scalar variable is a Perl variable that is used to store scalar data. It uses a dollar sign $ and followed by one or more alphanumeric characters or underscores. It is case sensitive.&lt;br /&gt;
&lt;br /&gt;
Why should I use the -w argument with my Perl programs?&lt;br /&gt;
Many Perl developers use the -w option of the interpreter, especially during the development stages of an application. This warning option turns on many warning messages that can help you understand and debug your applications.&lt;br /&gt;
To use this option on Unix systems, just include it on the first line of the program, like this:&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
If you develop Perl apps on a DOS/Windows computer, and you&#39;re creating a program named myApp.pl, you can turn on the warning messages when you run your program like this:&lt;br /&gt;
perl -w myApp.pl&lt;br /&gt;
&lt;br /&gt;
Assuming $_ contains HTML, which of the following substitutions will remove all tags in it?&lt;br /&gt;
1.s/&amp;lt;.*&amp;gt;//g;&lt;br /&gt;
2.s/&amp;lt;.*?&amp;gt;//gs;&lt;br /&gt;
3.s/&amp;lt;\/?[A-Z]\w*(?:\s+[A-Z]\w*(?:\s*=\s*(?:([&quot;&#39;]).*?\1|[\w-.]+))?)*\s*&amp;gt;//gsix;&lt;br /&gt;
&lt;br /&gt;
You can&#39;t do that.&lt;br /&gt;
If it weren&#39;t for HTML comments, improperly formatted HTML, and tags with interesting data like &amp;lt; SCRIPT &amp;gt;, you could do this. Alas, you cannot. It takes a lot more smarts, and quite frankly, a real parser.&lt;br /&gt;
&lt;br /&gt;
I want users send data by formmail but when they send nothing or call it from web site they will see error.&lt;br /&gt;
codes in PHP like this:&lt;br /&gt;
if (isset($HTTP_POST_VARS)){&lt;br /&gt;
..........&lt;br /&gt;
}&lt;br /&gt;
else{&lt;br /&gt;
echo (&quot;error lalalalal&quot;)&lt;br /&gt;
}&lt;br /&gt;
How it will look in perl?&lt;br /&gt;
&lt;br /&gt;
In php it will be like&lt;br /&gt;
if (isset($HTTP_POST_VARS)){&lt;br /&gt;
....&lt;br /&gt;
}&lt;br /&gt;
In perl, tried this.&lt;br /&gt;
if ($ENV{&#39;REQUEST_METHOD&#39;} eq &#39;POST&#39;){&lt;br /&gt;
.....&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
What is the output of the following Perl program?&lt;br /&gt;
1 $p1 = &quot;prog1.java&quot;;&lt;br /&gt;
2 $p1 =~ s/(.*)\.java/$1.cpp/;&lt;br /&gt;
3 print &quot;$p1\n&quot;;&lt;br /&gt;
&lt;br /&gt;
prog1.cpp&lt;br /&gt;
&lt;br /&gt;
Why aren&#39;t Perl&#39;s patterns regular expressions?&lt;br /&gt;
&lt;br /&gt;
Because Perl patterns have backreferences.&lt;br /&gt;
A regular expression by definition must be able to determine the next state in the finite automaton without requiring any extra memory to keep around previous state. A pattern /([ab]+)c\1/ requires the state machine to remember old states, and thus disqualifies such patterns as being regular expressions in the classic sense of the term.&lt;br /&gt;
&lt;br /&gt;
What does Perl do if you try to exploit the execve(2) race involving setuid scripts?&lt;br /&gt;
Sends mail to root and exits.&lt;br /&gt;
It has been said that all programs advance to the point of being able to automatically read mail. While not quite at that point (well, without having a module loaded), Perl does at least automatically send it.&lt;br /&gt;
&lt;br /&gt;
How do I do &amp;lt; fill-in-the-blank &amp;gt; for each element in a hash?&lt;br /&gt;
Here&#39;s a simple technique to process each element in a hash:&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
&lt;br /&gt;
%days = (&lt;br /&gt;
&#39;Sun&#39; =&amp;gt;&#39;Sunday&#39;,&lt;br /&gt;
&#39;Mon&#39; =&amp;gt; &#39;Monday&#39;,&lt;br /&gt;
&#39;Tue&#39; =&amp;gt; &#39;Tuesday&#39;,&lt;br /&gt;
&#39;Wed&#39; =&amp;gt; &#39;Wednesday&#39;,&lt;br /&gt;
&#39;Thu&#39; =&amp;gt; &#39;Thursday&#39;,&lt;br /&gt;
&#39;Fri&#39; =&amp;gt; &#39;Friday&#39;,&lt;br /&gt;
&#39;Sat&#39; =&amp;gt; &#39;Saturday&#39; );&lt;br /&gt;
&lt;br /&gt;
foreach $key (sort keys %days) {&lt;br /&gt;
print &quot;The long name for $key is $days{$key}.\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
How do I sort a hash by the hash key?&lt;br /&gt;
Suppose we have a class of five students.&lt;br /&gt;
Their names are kim, al, rocky, chrisy, and jane.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s a test program that prints the contents&lt;br /&gt;
of the grades hash, sorted by student name:&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
&lt;br /&gt;
%grades = (&lt;br /&gt;
kim =&amp;gt; 96,&lt;br /&gt;
al =&amp;gt; 63,&lt;br /&gt;
rocky =&amp;gt; 87,&lt;br /&gt;
chrisy =&amp;gt; 96,&lt;br /&gt;
jane =&amp;gt; 79,&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
print &quot;\n\tGRADES SORTED BY STUDENT NAME:\n&quot;;&lt;br /&gt;
foreach $key (sort (keys(%grades))) {&lt;br /&gt;
print &quot;\t\t$key \t\t$grades{$key}\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The output of this program looks like this:&lt;br /&gt;
&lt;br /&gt;
GRADES SORTED BY STUDENT NAME:&lt;br /&gt;
al 63&lt;br /&gt;
chrisy 96&lt;br /&gt;
jane 79&lt;br /&gt;
kim 96&lt;br /&gt;
rocky 87&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
How do you print out the next line from a filehandle with all its bytes reversed?&lt;br /&gt;
print scalar reverse scalar &amp;lt;FH&amp;gt;&lt;br /&gt;
Surprisingly enough, you have to put both the reverse and the &amp;lt;FH&amp;gt; into scalar context separately for this to work.&lt;br /&gt;
&lt;br /&gt;
How do I send e-mail from a Perl/CGI program on a Unix system?&lt;br /&gt;
Sending e-mail from a Perl/CGI program on a Unix computer system is usually pretty simple. Most Perl programs directly invoke the Unix sendmail program. We&#39;ll go through a quick example here.&lt;br /&gt;
Assuming that you&#39;ve already have e-mail information you need, such as the send-to address and subject, you can use these next steps to generate and send the e-mail message:&lt;br /&gt;
# the rest of your program is up here ...&lt;br /&gt;
open(MAIL, &quot;|/usr/lib/sendmail -t&quot;);&lt;br /&gt;
print MAIL &quot;To: $sendToAddress\n&quot;;&lt;br /&gt;
print MAIL &quot;From: $myEmailAddress\n&quot;;&lt;br /&gt;
print MAIL &quot;Subject: $subject\n&quot;;&lt;br /&gt;
print MAIL &quot;This is the message body.\n&quot;;&lt;br /&gt;
print MAIL &quot;Put your message here in the body.\n&quot;;&lt;br /&gt;
close (MAIL);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to read from a pipeline with Perl&lt;br /&gt;
Example 1:&lt;br /&gt;
&lt;br /&gt;
To run the date command from a Perl program, and read the output&lt;br /&gt;
of the command, all you need are a few lines of code like this:&lt;br /&gt;
&lt;br /&gt;
open(DATE, &quot;date|&quot;);&lt;br /&gt;
$theDate = &amp;lt;DATE&amp;gt;;&lt;br /&gt;
close(DATE);&lt;br /&gt;
&lt;br /&gt;
The open() function runs the external date command, then opens&lt;br /&gt;
a file handle DATE to the output of the date command.&lt;br /&gt;
&lt;br /&gt;
Next, the output of the date command is read into&lt;br /&gt;
the variable $theDate through the file handle DATE.&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
&lt;br /&gt;
The following code runs the &quot;ps -f&quot; command, and reads the output:&lt;br /&gt;
&lt;br /&gt;
open(PS_F, &quot;ps -f|&quot;);&lt;br /&gt;
while (&amp;lt;PS_F&amp;gt;) {&lt;br /&gt;
($uid,$pid,$ppid,$restOfLine) = split;&lt;br /&gt;
# do whatever I want with the variables here ...&lt;br /&gt;
}&lt;br /&gt;
close(PS_F);&lt;br /&gt;
&lt;br /&gt;
Why is it hard to call this function: sub y { &quot;because&quot; }&lt;br /&gt;
Because y is a kind of quoting operator.&lt;br /&gt;
The y/// operator is the sed-savvy synonym for tr///. That means y(3) would be like tr(), which would be looking for a second string, as in tr/a-z/A-Z/, tr(a-z)(A-Z), or tr[a-z][A-Z].&lt;br /&gt;
&lt;br /&gt;
What does `$result = f() .. g()&#39; really return?&lt;br /&gt;
False so long as f() returns false, after which it returns true until g() returns true, and then starts the cycle again.&lt;br /&gt;
This is scalar not list context, so we have the bistable flip-flop range operator famous in parsing of mail messages, as in `$in_body = /^$/ .. eof()&#39;. Except for the first time f() returns true, g() is entirely ignored, and f() will be ignored while g() later when g() is evaluated. Double dot is the inclusive range operator, f() and g() will both be evaluated on the same record. If you don&#39;t want that to happen, the exclusive range operator, triple dots, can be used instead. For extra credit, describe this:&lt;br /&gt;
$bingo = ( a() .. b() ) ... ( c() .. d() );&lt;br /&gt;
&lt;br /&gt;
Why does Perl not have overloaded functions?&lt;br /&gt;
Because you can inspect the argument count, return context, and object types all by yourself.&lt;br /&gt;
In Perl, the number of arguments is trivially available to a function via the scalar sense of @_, the return context via wantarray(), and the types of the arguments via ref() if they&#39;re references and simple pattern matching like /^\d+$/ otherwise. In languages like C++ where you can&#39;t do this, you simply must resort to overloading of functions.&lt;br /&gt;
&lt;br /&gt;
What does read() return at end of file?&lt;br /&gt;
0&lt;br /&gt;
A defined (but false) 0 value is the proper indication of the end of file for read() and sysread().&lt;br /&gt;
&lt;br /&gt;
What does `new $cur-&amp;gt;{LINK}&#39; do? (Assume the current package has no new() function of its own.)&lt;br /&gt;
$cur-&amp;gt;new()-&amp;gt;{LINK}&lt;br /&gt;
The indirect object syntax only has a single token lookahead. That means if new() is a method, it only grabs the very next token, not the entire following expression.&lt;br /&gt;
This is why `new $obj[23] arg&#39; does&#39;t work, as well as why `print $fh[23] &quot;stuff\n&quot;&#39; does&#39;t work. Mixing notations between the OO and IO notations is perilous. If you always use arrow syntax for method calls, and nothing else, you&#39;ll not be surprised.&lt;br /&gt;
&lt;br /&gt;
How do I sort a hash by the hash value?&lt;br /&gt;
Here&#39;s a program that prints the contents&lt;br /&gt;
of the grades hash, sorted numerically by the hash value:&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
&lt;br /&gt;
# Help sort a hash by the hash &#39;value&#39;, not the &#39;key&#39;.&lt;br /&gt;
to highest).&lt;br /&gt;
sub hashValueAscendingNum {&lt;br /&gt;
$grades{$a} &amp;lt;=&amp;gt; $grades{$b};&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Help sort a hash by the hash &#39;value&#39;, not the &#39;key&#39;.&lt;br /&gt;
# Values are returned in descending numeric order&lt;br /&gt;
# (highest to lowest).&lt;br /&gt;
sub hashValueDescendingNum {&lt;br /&gt;
$grades{$b} &amp;lt;=&amp;gt; $grades{$a};&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%grades = (&lt;br /&gt;
student1 =&amp;gt; 90,&lt;br /&gt;
student2 =&amp;gt; 75,&lt;br /&gt;
student3 =&amp;gt; 96,&lt;br /&gt;
student4 =&amp;gt; 55,&lt;br /&gt;
student5 =&amp;gt; 76,&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
print &quot;\n\tGRADES IN ASCENDING NUMERIC ORDER:\n&quot;;&lt;br /&gt;
foreach $key (sort hashValueAscendingNum (keys(%grades))) {&lt;br /&gt;
print &quot;\t\t$grades{$key} \t\t $key\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
print &quot;\n\tGRADES IN DESCENDING NUMERIC ORDER:\n&quot;;&lt;br /&gt;
foreach $key (sort hashValueDescendingNum (keys(%grades))) {&lt;br /&gt;
print &quot;\t\t$grades{$key} \t\t $key\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to read file into hash array ?&lt;br /&gt;
open(IN, &quot;&amp;lt;name_file&quot;)&lt;br /&gt;
or die &quot;Couldn&#39;t open file for processing: $!&quot;;&lt;br /&gt;
while (&amp;lt;IN&amp;gt;) {&lt;br /&gt;
chomp;&lt;br /&gt;
$hash_table{$_} = 0;&lt;br /&gt;
}&lt;br /&gt;
close IN;&lt;br /&gt;
&lt;br /&gt;
print &quot;$_ = $hash_table{$_}\n&quot; foreach keys %hash_table;&lt;br /&gt;
&lt;br /&gt;
How do you find the length of an array?&lt;br /&gt;
$@array&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/perl-frequently-asked-questions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-7294774278365097413</guid><pubDate>Sat, 16 Nov 2013 19:34:00 +0000</pubDate><atom:updated>2013-11-16T11:34:30.924-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Advanced use of sed command</category><category domain="http://www.blogger.com/atom/ns#">Most Asked Unix Questions</category><category domain="http://www.blogger.com/atom/ns#">Oracle for Unix</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Unix Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">useful tricks of sed command</category><title>Most Asked Unix Questions Part 2</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
UNIX is an open source operating system. It is a multiuser, multitasking operating system and developed in 1969 at AT &amp;amp; T’s laboratory. First, it was developed in assembly language but later it was recoded in ‘C’ language when this language developed by Dennis Ritchie. Actually, Unix is not an operating system, it is trademark which we use to say, is it unix like operating system or not. i.e. any operating follows the protocol which open group created for unix, it can be called as Unix operating system. E.g. BSD, HP-AX, Sequent, AIX.&lt;br /&gt;
&lt;br /&gt;
Let’s talk about UNIX interview questions and its answers:&lt;br /&gt;
&lt;br /&gt;
What is the difference between Linux and UNIX?&lt;br /&gt;
&lt;br /&gt;
Ans -- If any operating system follows the UNIX protocols then we can say that it is a unix operating system. E.g. BSD, HP-AX etc. In case of Linux, actually Linux is a kernel which is most important part of operating system. Operating system comprised kernel, device drivers, desktop, other application etc. so, Linux is not an operating system, it is just a kernel which operating system uses like Red hat Linux, Open Suse etc. These operating system uses Linux kernel so, we can say that these operating systems are Linux.&lt;br /&gt;
&lt;br /&gt;
Which command can we use to rename the file in Unix?&lt;br /&gt;
&lt;br /&gt;
Ans -- In unix, there is no separate command to rename the file. We have to use ‘mv command’ to rename the file as below.&lt;br /&gt;
root@hello:~/hello/test# ls&lt;br /&gt;
fil5 &amp;nbsp;file1 &amp;nbsp;file2 &amp;nbsp;file3 &amp;nbsp;file4 &amp;nbsp;test1&lt;br /&gt;
root@hello:~/hello/test#&lt;br /&gt;
root@hello:~/hello/test# mv file4 rename_file4&lt;br /&gt;
root@hello:~/hello/test# ls&lt;br /&gt;
fil5 &amp;nbsp;file1 &amp;nbsp;file2 &amp;nbsp;file3 &amp;nbsp;rename_file4 &amp;nbsp;test1&lt;br /&gt;
root@hello:~/hello/test#&lt;br /&gt;
&lt;br /&gt;
Use of command:&lt;br /&gt;
mv source_file destination_file&lt;br /&gt;
&lt;br /&gt;
What is sed?&lt;br /&gt;
&lt;br /&gt;
Ans -- Sed is a stream editor used to parse and transform the text. Sed does specified operations line by line on each line of input file or stream. Sed script either command line script or separate file.&lt;br /&gt;
&lt;br /&gt;
Is sed command edit file?&lt;br /&gt;
&lt;br /&gt;
Ans -- Yes. Sed command can edit the file. But this feature is available in Linux like operating only. This feature is not available in Solaris.&lt;br /&gt;
&lt;br /&gt;
What is alias and how to do it? What is the use of it?&lt;br /&gt;
&lt;br /&gt;
Ans -- Alias used to map some letters to specific command and instead of running that command, just type those letters. Please see below example to map ‘ls –l’ command to ‘ll’ letters.&lt;br /&gt;
&lt;br /&gt;
root@01hw394566:~/ctier/test# alias&lt;br /&gt;
alias ls=&#39;ls --color=auto&#39;&lt;br /&gt;
root@01hw394566:~/ctier/test#&lt;br /&gt;
root@01hw394566:~/ctier/test# alias ll=&#39;ls -l&#39;&lt;br /&gt;
root@01hw394566:~/ctier/test# alias&lt;br /&gt;
alias ll=&#39;ls -l&#39;&lt;br /&gt;
alias ls=&#39;ls --color=auto&#39;&lt;br /&gt;
root@01hw394566:~/ctier/test#&lt;br /&gt;
root@01hw394566:~/ctier/test# ll&lt;br /&gt;
total 4&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 fil5&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 file1&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 file2&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 file3&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 rename_file4&lt;br /&gt;
-rw-r--r-- 1 root root 20 2013-07-30 20:09 test1&lt;br /&gt;
root@01hw394566:~/ctier/test#&lt;br /&gt;
&lt;br /&gt;
Which daemons are running for NFS service?&lt;br /&gt;
&lt;br /&gt;
Ans -- There are many NFS service daemons are running when we start the service. These daemons as follows:&lt;br /&gt;
Nfs&lt;br /&gt;
Nfsblock&lt;br /&gt;
Rpcbind&lt;br /&gt;
Rpc.mountd&lt;br /&gt;
Rpc.nfsd&lt;br /&gt;
Lockd&lt;br /&gt;
Rpc.statd&lt;br /&gt;
Rpc.rquotad&lt;br /&gt;
Rpc.idmapd&lt;br /&gt;
&lt;br /&gt;
What is NFS port number and main configuration file?&lt;br /&gt;
&lt;br /&gt;
Ans -- NFS service is using 2049 port and its main configuration file is /etc/exports.&lt;br /&gt;
&lt;br /&gt;
What is port number for https?&lt;br /&gt;
&lt;br /&gt;
Ans -- Https port number is 443.&lt;br /&gt;
&lt;br /&gt;
How to strip all html tags from a file using sed command?&lt;br /&gt;
&lt;br /&gt;
Ans – please find below example for stripping all html tags from a file using sed command.&lt;br /&gt;
&lt;br /&gt;
root@01hw394566:~/ctier/test# cat test.html&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;&lt;br /&gt;
Hello, Linux Administrator...!!!&lt;br /&gt;
&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
root@01hw394566:~/ctier/test# sed -e &#39;s/&amp;lt;[^&amp;gt;]*&amp;gt;//g&#39; test.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hello, Linux Administrator...!!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root@01hw394566:~/ctier/test# sed -e &#39;s/&amp;lt;[^&amp;gt;]*&amp;gt;//g&#39; -e &#39;/^$/ d&#39; test.html&lt;br /&gt;
Hello, Linux Administrator...!!!&lt;br /&gt;
root@01hw394566:~/ctier/test#&lt;br /&gt;
&lt;br /&gt;
If you have seen in above example, we see that after stripping html tags, there are blank lines as it is. That’s why, we have used sed again to strip all blank lines.&lt;br /&gt;
&lt;br /&gt;
What is inode?&lt;br /&gt;
&lt;br /&gt;
Inode is a data structure found in unix file system. Each inode stores all the information about a file system object except data content and file name. We can see any file’s inode by command as “ls –i file name”. Inode is a unique in a file system. Inode contains following information:&lt;br /&gt;
File Type&lt;br /&gt;
Permissions (read, write, execute)&lt;br /&gt;
Owner&lt;br /&gt;
Group&lt;br /&gt;
File Size&lt;br /&gt;
File access, change, modification time&lt;br /&gt;
File deletion time&lt;br /&gt;
Number of links&lt;br /&gt;
Access control list&lt;br /&gt;
&lt;br /&gt;
How do I see a inode number of file?&lt;br /&gt;
&lt;br /&gt;
Ans – Please see below example.&lt;br /&gt;
&lt;br /&gt;
root@01hw394566:~/ctier/test# ls –li&lt;br /&gt;
total 8&lt;br /&gt;
1206521 -rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 fil5&lt;br /&gt;
1206512 -rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 file1&lt;br /&gt;
1206515 -rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 file2&lt;br /&gt;
1206516 -rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 file3&lt;br /&gt;
1206559 drwxr-xr-x 2 root root 4096 2013-08-05 21:39 how&lt;br /&gt;
1206517 -rw-r--r-- 1 root root &amp;nbsp;0 2013-07-30 20:09 rename_file4&lt;br /&gt;
1206556 -rw-r--r-- 1 root root 20 2013-07-30 20:09 test1&lt;br /&gt;
1206560 -rw-r--r-- 1 root root 72 2013-08-05 20:22 test.html&lt;br /&gt;
root@01hw394566:~/ctier/test#&lt;br /&gt;
&lt;br /&gt;
How to check port is open or not in Unix?&lt;br /&gt;
&lt;br /&gt;
Ans— We can check port is open or not in Unix by netstat command. Please see below example for checking for port 80.&lt;br /&gt;
root@01hw394566:~/ctier/test# netstat -aeen | grep -w 80&lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 127.0.0.1:80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.0.0.0:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LISTEN &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8817&lt;br /&gt;
root@01hw394566:~/ctier/test#&lt;br /&gt;
&lt;br /&gt;
If you see port 80 is tcp port. We have used double e option to get more detailed information about this port.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/most-asked-unix-questions-part-2.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-5862020454733038745</guid><pubDate>Sat, 16 Nov 2013 19:34:00 +0000</pubDate><atom:updated>2013-11-16T11:34:27.075-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Shell scripting interview questions and answers</category><category domain="http://www.blogger.com/atom/ns#">Top 25 Unix interview questions with answers</category><title>Most Asked Unix Questions Part 1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
How to print/display the first line of a file?&lt;br /&gt;
There are many ways to do this. However the easiest way to display the first line of a file is using the [head] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; head -1 file.txt&lt;br /&gt;
No prize in guessing that if you specify [head -2] then it would print first 2 records of the file.&lt;br /&gt;
&lt;br /&gt;
Another way can be by using [sed] command. [Sed] is a very powerful text editor which can be used for various text manipulation purposes like this.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed &#39;2,$ d&#39; file.txt&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
You may be wondering how does the above command work? OK, the &#39;d&#39; parameter basically tells [sed] to delete all the records from display output from line no. 2 to last line of the file (last line is represented by $ symbol). Of course it does not actually delete those lines from the file, it just does not display those lines in standard output screen. So you only see the remaining line which is the first line.&lt;br /&gt;
&lt;br /&gt;
How to print/display the last line of a file?&lt;br /&gt;
The easiest way is to use the [tail] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; tail -1 file.txt&lt;br /&gt;
If you want to do it using [sed] command, here is what you should write:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed -n &#39;$ p&#39; test&lt;br /&gt;
From our previous answer, we already know that &#39;$&#39; stands for the last line of the file. So &#39;$ p&#39; basically prints (p for print) the last line in standard output screen. &#39;-n&#39; switch takes [sed] to silent mode so that [sed] does not print anything else in the output.&lt;br /&gt;
&lt;br /&gt;
How to display n-th line of a file?&lt;br /&gt;
The easiest way to do it will be by using [sed] I guess. Based on what we already know about [sed] from our previous examples, we can quickly deduce this command:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;&amp;lt;n&amp;gt; p&#39; file.txt&lt;br /&gt;
You need to replace &amp;lt;n&amp;gt; with the actual line number. So if you want to print the 4th line, the command will be&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;4 p&#39; test&lt;br /&gt;
Of course you can do it by using [head] and [tail] command as well like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; head -&amp;lt;n&amp;gt; file.txt | tail -1&lt;br /&gt;
You need to replace &amp;lt;n&amp;gt; with the actual line number. So if you want to print the 4th line, the command will be&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; head -4 file.txt | tail -1&lt;br /&gt;
How to remove the first line / header from a file?&lt;br /&gt;
We already know how [sed] can be used to delete a certain line from the output – by using the&#39;d&#39; switch. So if we want to delete the first line the command should be:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed &#39;1 d&#39; file.txt&lt;br /&gt;
But the issue with the above command is, it just prints out all the lines except the first line of the file on the standard output. It does not really change the file in-place. So if you want to delete the first line from the file itself, you have two options.&lt;br /&gt;
&lt;br /&gt;
Either you can redirect the output of the file to some other file and then rename it back to original file like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed &#39;1 d&#39; file.txt &amp;gt; new_file.txt&lt;br /&gt;
$&amp;gt; mv new_file.txt file.txt&lt;br /&gt;
Or, you can use an inbuilt [sed] switch &#39;–i&#39; which changes the file in-place. See below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;1 d&#39; file.txt&lt;br /&gt;
How to remove the last line/ trailer from a file in Unix script?&lt;br /&gt;
Always remember that [sed] switch &#39;$&#39; refers to the last line. So using this knowledge we can deduce the below command:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;$ d&#39; file.txt&lt;br /&gt;
How to remove certain lines from a file in Unix?&lt;br /&gt;
If you want to remove line &amp;lt;m&amp;gt; to line &amp;lt;n&amp;gt; from a given file, you can accomplish the task in the similar method shown above. Here is an example:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;5,7 d&#39; file.txt&lt;br /&gt;
The above command will delete line 5 to line 7 from the file file.txt&lt;br /&gt;
&lt;br /&gt;
How to remove the last n-th line from a file?&lt;br /&gt;
This is bit tricky. Suppose your file contains 100 lines and you want to remove the last 5 lines. Now if you know how many lines are there in the file, then you can simply use the above shown method and can remove all the lines from 96 to 100 like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –i &#39;96,100 d&#39; file.txt &amp;nbsp; # alternative to command [head -95 file.txt]&lt;br /&gt;
But not always you will know the number of lines present in the file (the file may be generated dynamically, etc.) In that case there are many different ways to solve the problem. There are some ways which are quite complex and fancy. But let&#39;s first do it in a way that we can understand easily and remember easily. Here is how it goes:&lt;br /&gt;
$&amp;gt; tt=`wc -l file.txt | cut -f1 -d&#39; &#39;`;sed –i &quot;`expr $tt - 4`,$tt d&quot; test&lt;br /&gt;
As you can see there are two commands. The first one (before the semi-colon) calculates the total number of lines present in the file and stores it in a variable called “tt”. The second command (after the semi-colon), uses the variable and works in the exact way as shows in the previous example.&lt;br /&gt;
How to check the length of any line in a file?&lt;br /&gt;
We already know how to print one line from a file which is this:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; sed –n &#39;&amp;lt;n&amp;gt; p&#39; file.txt&lt;br /&gt;
Where &amp;lt;n&amp;gt; is to be replaced by the actual line number that you want to print. Now once you know it, it is easy to print out the length of this line by using [wc] command with &#39;-c&#39; switch.&lt;br /&gt;
$&amp;gt; sed –n &#39;35 p&#39; file.txt | wc –c&lt;br /&gt;
The above command will print the length of 35th line in the file.txt.&lt;br /&gt;
How to get the nth word of a line in Unix?&lt;br /&gt;
Assuming the words in the line are separated by space, we can use the [cut] command. [cut] is a very powerful and useful command and it&#39;s real easy. All you have to do to get the n-th word from the line is issue the following command:&lt;br /&gt;
&lt;br /&gt;
cut –f&amp;lt;n&amp;gt; -d&#39; &#39;&lt;br /&gt;
&#39;-d&#39; switch tells [cut] about what is the delimiter (or separator) in the file, which is space &#39; &#39; in this case. If the separator was comma, we could have written -d&#39;,&#39; then. So, suppose I want find the 4th word from the below string: “A quick brown fox jumped over the lazy cat”, we will do something like this:&lt;br /&gt;
$&amp;gt; echo “A quick brown fox jumped over the lazy cat” | cut –f4 –d&#39; &#39;&lt;br /&gt;
And it will print “fox”&lt;br /&gt;
How to reverse a string in unix?&lt;br /&gt;
Pretty easy. Use the [rev] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; echo &quot;unix&quot; | rev&lt;br /&gt;
xinu&lt;br /&gt;
How to get the last word from a line in Unix file?&lt;br /&gt;
We will make use of two commands that we learnt above to solve this. The commands are [rev] and [cut]. Here we go.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s imagine the line is: “C for Cat”. We need “Cat”. First we reverse the line. We get “taC rof C”. Then we cut the first word, we get &#39;taC&#39;. And then we reverse it again.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;echo &quot;C for Cat&quot; | rev | cut -f1 -d&#39; &#39; | rev&lt;br /&gt;
Cat&lt;br /&gt;
How to get the n-th field from a Unix command output?&lt;br /&gt;
We know we can do it by [cut]. Like below command extracts the first field from the output of [wc –c] command&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;wc -c file.txt | cut -d&#39; &#39; -f1&lt;br /&gt;
109&lt;br /&gt;
But I want to introduce one more command to do this here. That is by using [awk] command. [awk] is a very powerful command for text pattern scanning and processing. Here we will see how may we use of [awk] to extract the first field (or first column) from the output of another command. Like above suppose I want to print the first column of the [wc –c] output. Here is how it goes like this:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;wc -c file.txt | awk &#39; &#39;&#39;{print $1}&#39;&lt;br /&gt;
109&lt;br /&gt;
The basic syntax of [awk] is like this:&lt;br /&gt;
&lt;br /&gt;
awk &#39;pattern space&#39;&#39;{action space}&#39;&lt;br /&gt;
The pattern space can be left blank or omitted, like below:&lt;br /&gt;
$&amp;gt;wc -c file.txt | awk &#39;{print $1}&#39;&lt;br /&gt;
109&lt;br /&gt;
In the action space, we have asked [awk] to take the action of printing the first column ($1). More on [awk] later.&lt;br /&gt;
How to replace the n-th line in a file with a new line in Unix?&lt;br /&gt;
This can be done in two steps. The first step is to remove the n-th line. And the second step is to insert a new line in n-th line position. Here we go.&lt;br /&gt;
&lt;br /&gt;
Step 1: remove the n-th line&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;sed -i&#39;&#39; &#39;10 d&#39; file.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; # d stands for delete&lt;br /&gt;
Step 2: insert a new line at n-th line position&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;sed -i&#39;&#39; &#39;10 i This is the new line&#39; file.txt &amp;nbsp; &amp;nbsp; # i stands for insert&lt;br /&gt;
How to show the non-printable characters in a file?&lt;br /&gt;
Open the file in VI editor. Go to VI command mode by pressing [Escape] and then [:]. Then type [set list]. This will show you all the non-printable characters, e.g. Ctrl-M characters (^M) etc., in the file.&lt;br /&gt;
&lt;br /&gt;
How to zip a file in Linux?&lt;br /&gt;
Use inbuilt [zip] command in Linux&lt;br /&gt;
&lt;br /&gt;
How to unzip a file in Linux?&lt;br /&gt;
Use inbuilt [unzip] command in Linux.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; unzip –j file.zip&lt;br /&gt;
How to test if a zip file is corrupted in Linux?&lt;br /&gt;
Use “-t” switch with the inbuilt [unzip] command&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; unzip –t file.zip&lt;br /&gt;
How to check if a file is zipped in Unix?&lt;br /&gt;
In order to know the file type of a particular file use the [file] command like below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; file file.txt&lt;br /&gt;
file.txt: ASCII text&lt;br /&gt;
If you want to know the technical MIME type of the file, use “-i” switch.&lt;br /&gt;
$&amp;gt;file -i file.txt&lt;br /&gt;
file.txt: text/plain; charset=us-ascii&lt;br /&gt;
If the file is zipped, following will be the result&lt;br /&gt;
$&amp;gt; file –i file.zip&lt;br /&gt;
file.zip: application/x-zip&lt;br /&gt;
How to connect to Oracle database from within shell script?&lt;br /&gt;
You will be using the same [sqlplus] command to connect to database that you use normally even outside the shell script. To understand this, let&#39;s take an example. In this example, we will connect to database, fire a query and get the output printed from the unix shell. Ok? Here we go –&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;res=`sqlplus -s username/password@database_name &amp;lt;&amp;lt;EOF&lt;br /&gt;
SET HEAD OFF;&lt;br /&gt;
select count(*) from dual;&lt;br /&gt;
EXIT;&lt;br /&gt;
EOF`&lt;br /&gt;
$&amp;gt; echo $res&lt;br /&gt;
1&lt;br /&gt;
If you connect to database in this method, the advantage is, you will be able to pass Unix side shell variables value to the database. See below example&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;res=`sqlplus -s username/password@database_name &amp;nbsp;&amp;lt;&amp;lt;EOF&lt;br /&gt;
SET HEAD OFF;&lt;br /&gt;
select count(*) from student_table t where t.last_name=$1;&lt;br /&gt;
EXIT;&lt;br /&gt;
EOF`&lt;br /&gt;
$&amp;gt; echo $res&lt;br /&gt;
12&lt;br /&gt;
How to execute a database stored procedure from Shell script?&lt;br /&gt;
$&amp;gt; SqlReturnMsg=`sqlplus -s username/password@database&amp;lt;&amp;lt;EOF&lt;br /&gt;
BEGIN&lt;br /&gt;
Proc_Your_Procedure(… your-input-parameters …);&lt;br /&gt;
END;&lt;br /&gt;
/&lt;br /&gt;
EXIT;&lt;br /&gt;
EOF`&lt;br /&gt;
$&amp;gt; echo $SqlReturnMsg&lt;br /&gt;
How to check the command line arguments in a UNIX command in Shell Script?&lt;br /&gt;
In a bash shell, you can access the command line arguments using $0, $1, $2, … variables, where $0 prints the command name, $1 prints the first input parameter of the command, $2 the second input parameter of the command and so on.&lt;br /&gt;
&lt;br /&gt;
How to fail a shell script programmatically?&lt;br /&gt;
Just put an [exit] command in the shell script with return value other than 0. this is because the exit codes of successful Unix programs is zero. So, suppose if you write&lt;br /&gt;
&lt;br /&gt;
exit -1&lt;br /&gt;
inside your program, then your program will thrown an error and exit immediately.&lt;br /&gt;
How to list down file/folder lists alphabetically?&lt;br /&gt;
Normally [ls –lt] command lists down file/folder list sorted by modified time. If you want to list then alphabetically, then you should simply specify: [ls –l]&lt;br /&gt;
&lt;br /&gt;
How to check if the last command was successful in Unix?&lt;br /&gt;
To check the status of last executed command in UNIX, you can check the value of an inbuilt bash variable [$?]. See the below example:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; echo $?&lt;br /&gt;
How to check if a file is present in a particular directory in Unix?&lt;br /&gt;
Using command, we can do it in many ways. Based on what we have learnt so far, we can make use of [ls] and [$?] command to do this. See below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; ls –l file.txt; echo $?&lt;br /&gt;
If the file exists, the [ls] command will be successful. Hence [echo $?] will print 0. If the file does not exist, then [ls] command will fail and hence [echo $?] will print 1.&lt;br /&gt;
How to check all the running processes in Unix?&lt;br /&gt;
The standard command to see this is [ps]. But [ps] only shows you the snapshot of the processes at that instance. If you need to monitor the processes for a certain period of time and need to refresh the results in each interval, consider using the [top] command.&lt;br /&gt;
&lt;br /&gt;
$&amp;gt; ps –ef&lt;br /&gt;
If you wish to see the % of memory usage and CPU usage, then consider the below switches&lt;br /&gt;
$&amp;gt; ps aux&lt;br /&gt;
If you wish to use this command inside some shell script, or if you want to customize the output of [ps] command, you may use “-o” switch like below. By using “-o” switch, you can specify the columns that you want [ps] to print out.&lt;br /&gt;
$&amp;gt;ps -e -o stime,user,pid,args,%mem,%cpu&lt;br /&gt;
How to tell if my process is running in Unix?&lt;br /&gt;
You can list down all the running processes using [ps] command. Then you can “grep” your user name or process name to see if the process is running. See below:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;ps -e -o stime,user,pid,args,%mem,%cpu | grep &quot;opera&quot;&lt;br /&gt;
14:53 opera 29904 sleep 60 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.0 &amp;nbsp;0.0&lt;br /&gt;
14:54 opera 31536 ps -e -o stime,user,pid,arg &amp;nbsp;0.0 &amp;nbsp;0.0&lt;br /&gt;
14:54 opera 31538 grep opera &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.0 &amp;nbsp;0.0&lt;br /&gt;
How to get the CPU and Memory details in Linux server?&lt;br /&gt;
In Linux based systems, you can easily access the CPU and memory details from the /proc/cpuinfo and /proc/meminfo, like this:&lt;br /&gt;
&lt;br /&gt;
$&amp;gt;cat /proc/meminfo&lt;br /&gt;
$&amp;gt;cat /proc/cpuinfo&lt;br /&gt;
Just try the above commands in your system to see how it works&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/most-asked-unix-questions-part-1.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6755173720995974466.post-821598250479993770</guid><pubDate>Tue, 12 Nov 2013 16:22:00 +0000</pubDate><atom:updated>2013-11-16T11:36:10.821-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Perl</category><category domain="http://www.blogger.com/atom/ns#">Perl For Interview</category><category domain="http://www.blogger.com/atom/ns#">Perl Frequently Asked Questions</category><category domain="http://www.blogger.com/atom/ns#">Perl Interview Questions</category><category domain="http://www.blogger.com/atom/ns#">Perl Scripting</category><category domain="http://www.blogger.com/atom/ns#">Top 10 Perl Interview Questions</category><title>Perl Most Ask Questions and Answers - Part1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Those who want to pursue there career in perl ... here are the things which you need to know most......&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;I have also collected these from the web.... so you may find them at many other places also.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 115%;&quot;&gt;Why do you
use Perl?&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl is a
powerful free interpreter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl is
portable, flexible and easy to learn.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I set
environment variables in Perl programs?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;you can just
do something like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$path =
$ENV{&#39;PATH&#39;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;As you may
remember, &quot;%ENV&quot; is a special hash in Perl that contains the value of
all your environment variables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Because %ENV
is a hash, you can set environment variables just as you&#39;d set the value of any
Perl hash variable. Here&#39;s how you can set your PATH variable to make sure the
following four directories are in your path::&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$ENV{&#39;PATH&#39;}
= &#39;/bin:/usr/bin:/usr/local/bin:/home/yourname/bin&#39;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 115%;&quot;&gt;How do I do
fill_in_the_blank for each file in a directory?&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s code
that just prints a listing of every file in the current directory:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;opendir(DIR,
&quot;.&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@files =
readdir(DIR);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;closedir(DIR);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $file
(@files) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$file\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I do
fill_in_the_blank for each file in a directory?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s code
that just prints a listing of every file in the current directory:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;opendir(DIR,
&quot;.&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@files =
readdir(DIR);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;closedir(DIR);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $file
(@files) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$file\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I
generate a list of all .html files in a directory?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s a
snippet of code that just prints a listing of every file in the current
directory that ends with the extension .html:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;opendir(DIR,
&quot;.&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@files =
grep(/\.html$/,readdir(DIR));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;closedir(DIR);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $file
(@files) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$file\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;Which of these is a difference between C++ and Perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;Perl can have objects whose data cannot be accessed outside its class, but C++ cannot.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;Perl can use closures with unreachable private data as objects, and C++ doesn&#39;t support closures. Furthermore, C++ does support pointer arithmetic via `int *ip = (int*)&amp;amp;object&#39;, allowing you do look all over the object. Perl doesn&#39;t have pointer arithmetic. It also doesn&#39;t allow `#define private public&#39; to change access rights to foreign objects. On the other hand, once you start poking around in /dev/mem, no one is safe.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;How to open and read data files with Perl&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;Data files are opened in Perl using the open() function. When you open a data file, all you have to do is specify (a) a file handle and (b) the name of the file you want to read from.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;As an example, suppose you need to read some data from a file named &quot;checkbook.txt&quot;. Here&#39;s a simple open statement that opens the checkbook file for read access: open (CHECKBOOK, &quot;checkbook.txt&quot;); In this example, the name &quot;CHECKBOOK&quot; is the file handle that you&#39;ll use later when reading from the checkbook.txt data file. Any time you want to read data from the checkbook file, just use the file handle named &quot;CHECKBOOK&quot;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;Now that we&#39;ve opened the checkbook file, we&#39;d like to be able to read what&#39;s in it. Here&#39;s how to read one line of data from the checkbook file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;$record = &amp;lt; CHECKBOOK &amp;gt; ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;After this statement is executed, the variable $record contains the contents of the first line of the checkbook file. The &quot;&amp;lt;&amp;gt;&quot; symbol is called the line reading operator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;To print every record of information from the checkbook file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;open (CHECKBOOK, &quot;checkbook.txt&quot;) || die &quot;couldn&#39;t open the file!&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;while ($record = &amp;lt; CHECKBOOK &amp;gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;print $record;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9pt; line-height: 13px;&quot;&gt;close(CHECKBOOK);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What is Perl
one-liner?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;There are two
ways a Perl script can be run:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;--from a
command line, called one-liner, that means you type and execute immediately on
the command line. You&#39;ll need the -e option to start like &quot;C:\ %gt perl -e
&quot;print \&quot;Hello\&quot;;&quot;. One-liner doesn&#39;t mean one Perl
statement. One-liner may contain many statements in one line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;--from a
script file, called Perl program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Assuming both
a local($var) and a my($var) exist, what&#39;s the difference between ${var} and
${&quot;var&quot;}?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;${var} is the
lexical variable $var, and ${&quot;var&quot;} is the dynamic variable $var.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Note that because
the second is a symbol table lookup, it is disallowed under `use strict
&quot;refs&quot;&#39;. The words global, local, package, symbol table, and dynamic
all refer to the kind of variables that local() affects, whereas the other
sort, those governed by my(), are variously knows as private, lexical, or
scoped variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What happens
when you return a reference to a private variable?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl keeps
track of your variables, whether dynamic or otherwise, and doesn&#39;t free things
before you&#39;re done using them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How to turn
on Perl warnings? Why is that important?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl is very
forgiving of strange and sometimes wrong code, which can mean hours spent
searching for bugs and weird results. Turning on warnings helps uncover common
mistakes and strange places and save a lot of debugging time in the long run.
There are various ways of turning on Perl warnings:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;For Perl
one-liner, use -w option on the command line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;On Unix or
Windows, use the -w option in the shebang line (The first # line in the
script). Note: Windows Perl interpreter may not require it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;For other
systems, choose compiler warnings, or check compiler documentation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What are
scalar data and scalar variables?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl has a
flexible concept of data types. Scalar means a single thing, like a number or
string. So the Java concept of int, float, double and string equals to Perl\&#39;s
scalar in concept and the numbers and strings are exchangeable. Scalar variable
is a Perl variable that is used to store scalar data. It uses a dollar sign $
and followed by one or more alphanumeric characters or underscores. It is case
sensitive.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Why should I
use the -w argument with my Perl programs?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Many Perl
developers use the -w option of the interpreter, especially during the
development stages of an application. This warning option turns on many warning
messages that can help you understand and debug your applications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;To use this
option on Unix systems, just include it on the first line of the program, like
this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;If you
develop Perl apps on a DOS/Windows computer, and you&#39;re creating a program
named myApp.pl, you can turn on the warning messages when you run your program
like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;perl -w
myApp.pl&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Assuming $_
contains HTML, which of the following substitutions will remove all tags in it?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;1.s/&amp;lt;.*&amp;gt;//g;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;2.s/&amp;lt;.*?&amp;gt;//gs;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;3.s/&amp;lt;\/?[A-Z]\w*(?:\s+[A-Z]\w*(?:\s*=\s*(?:([&quot;&#39;]).*?\1|[\w-.]+))?)*\s*&amp;gt;//gsix;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;You can&#39;t do
that.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;If it weren&#39;t
for HTML comments, improperly formatted HTML, and tags with interesting data
like &amp;lt; SCRIPT &amp;gt;, you could do this. Alas, you cannot. It takes a lot more
smarts, and quite frankly, a real parser. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;I want users
send data by formmail but when they send nothing or call it from web site they
will see error.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;codes in PHP
like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;if
(isset($HTTP_POST_VARS)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;..........&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;else{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;echo
(&quot;error lalalalal&quot;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How it will
look in perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;In php it
will be like&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;if
(isset($HTTP_POST_VARS)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;....&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;In perl,
tried this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;if
($ENV{&#39;REQUEST_METHOD&#39;} eq &#39;POST&#39;){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;.....&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What is the
output of the following Perl program?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;1 $p1 =
&quot;prog1.java&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;2 $p1 =~
s/(.*)\.java/$1.cpp/;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;3 print
&quot;$p1\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;prog1.cpp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Why aren&#39;t
Perl&#39;s patterns regular expressions?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Because Perl
patterns have backreferences.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;A regular
expression by definition must be able to determine the next state in the finite
automaton without requiring any extra memory to keep around previous state. A
pattern /([ab]+)c\1/ requires the state machine to remember old states, and
thus disqualifies such patterns as being regular expressions in the classic
sense of the term.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What does
Perl do if you try to exploit the execve(2) race involving setuid scripts?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Sends mail to
root and exits.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;It has been
said that all programs advance to the point of being able to automatically read
mail. While not quite at that point (well, without having a module loaded),
Perl does at least automatically send it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I do
&amp;lt; fill-in-the-blank &amp;gt; for each element in a hash?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s a
simple technique to process each element in a hash:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;%days = (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Sun&#39;
=&amp;gt;&#39;Sunday&#39;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Mon&#39; =&amp;gt;
&#39;Monday&#39;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Tue&#39; =&amp;gt;
&#39;Tuesday&#39;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Wed&#39; =&amp;gt;
&#39;Wednesday&#39;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Thu&#39; =&amp;gt;
&#39;Thursday&#39;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Fri&#39; =&amp;gt;
&#39;Friday&#39;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&#39;Sat&#39; =&amp;gt;
&#39;Saturday&#39; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $key
(sort keys %days) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;The long name for $key is $days{$key}.\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I sort
a hash by the hash key?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Suppose we
have a class of five students.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Their names
are kim, al, rocky, chrisy, and jane.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s a test
program that prints the contents&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;of the grades
hash, sorted by student name:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;%grades = (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;kim =&amp;gt; 96,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;al =&amp;gt; 63,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;rocky =&amp;gt;
87,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;chrisy =&amp;gt;
96,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;jane =&amp;gt;
79,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;\n\tGRADES SORTED BY STUDENT NAME:\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $key
(sort (keys(%grades))) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;\t\t$key \t\t$grades{$key}\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The output of
this program looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;GRADES SORTED
BY STUDENT NAME:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;al 63&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;chrisy 96&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;jane 79&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;kim 96&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;rocky 87&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do you
print out the next line from a filehandle with all its bytes reversed?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print scalar
reverse scalar &amp;lt;FH&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Surprisingly
enough, you have to put both the reverse and the &amp;lt;FH&amp;gt; into scalar context
separately for this to work.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I send
e-mail from a Perl/CGI program on a Unix system?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Sending
e-mail from a Perl/CGI program on a Unix computer system is usually pretty
simple. Most Perl programs directly invoke the Unix sendmail program. We&#39;ll go
through a quick example here.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Assuming that
you&#39;ve already have e-mail information you need, such as the send-to address
and subject, you can use these next steps to generate and send the e-mail
message:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;# the rest of
your program is up here ...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;open(MAIL,
&quot;|/usr/lib/sendmail -t&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print MAIL
&quot;To: $sendToAddress\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print MAIL
&quot;From: $myEmailAddress\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print MAIL
&quot;Subject: $subject\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print MAIL
&quot;This is the message body.\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print MAIL
&quot;Put your message here in the body.\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;close (MAIL);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How to read
from a pipeline with Perl&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Example 1:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;To run the
date command from a Perl program, and read the output&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;of the command,
all you need are a few lines of code like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;open(DATE,
&quot;date|&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$theDate =
&amp;lt;DATE&amp;gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;close(DATE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The open()
function runs the external date command, then opens&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;a file handle
DATE to the output of the date command.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Next, the
output of the date command is read into&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;the variable
$theDate through the file handle DATE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Example 2:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The following
code runs the &quot;ps -f&quot; command, and reads the output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;open(PS_F,
&quot;ps -f|&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;while
(&amp;lt;PS_F&amp;gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;($uid,$pid,$ppid,$restOfLine)
= split;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;# do whatever
I want with the variables here ...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;close(PS_F);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Why is it
hard to call this function: sub y { &quot;because&quot; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Because y is
a kind of quoting operator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The y///
operator is the sed-savvy synonym for tr///. That means y(3) would be like
tr(), which would be looking for a second string, as in tr/a-z/A-Z/,
tr(a-z)(A-Z), or tr[a-z][A-Z].&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What does
`$result = f() .. g()&#39; really return?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;False so long
as f() returns false, after which it returns true until g() returns true, and
then starts the cycle again.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;This is
scalar not list context, so we have the bistable flip-flop range operator
famous in parsing of mail messages, as in `$in_body = /^$/ .. eof()&#39;. Except
for the first time f() returns true, g() is entirely ignored, and f() will be
ignored while g() later when g() is evaluated. Double dot is the inclusive
range operator, f() and g() will both be evaluated on the same record. If you
don&#39;t want that to happen, the exclusive range operator, triple dots, can be
used instead. For extra credit, describe this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$bingo = (
a() .. b() ) ... ( c() .. d() );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Why does Perl
not have overloaded functions?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Because you
can inspect the argument count, return context, and object types all by
yourself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;In Perl, the
number of arguments is trivially available to a function via the scalar sense
of @_, the return context via wantarray(), and the types of the arguments via
ref() if they&#39;re references and simple pattern matching like /^\d+$/ otherwise.
In languages like C++ where you can&#39;t do this, you simply must resort to
overloading of functions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What does
read() return at end of file?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;A defined
(but false) 0 value is the proper indication of the end of file for read() and
sysread().&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What does
`new $cur-&amp;gt;{LINK}&#39; do? (Assume the current package has no new() function of
its own.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$cur-&amp;gt;new()-&amp;gt;{LINK}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The indirect
object syntax only has a single token lookahead. That means if new() is a
method, it only grabs the very next token, not the entire following expression.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;This is why
`new $obj[23] arg&#39; does&#39;t work, as well as why `print $fh[23]
&quot;stuff\n&quot;&#39; does&#39;t work. Mixing notations between the OO and IO
notations is perilous. If you always use arrow syntax for method calls, and
nothing else, you&#39;ll not be surprised.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I sort
a hash by the hash value?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s a
program that prints the contents&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;of the grades
hash, sorted numerically by the hash value:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;# Help sort a
hash by the hash &#39;value&#39;, not the &#39;key&#39;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;to highest).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;sub
hashValueAscendingNum {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$grades{$a}
&amp;lt;=&amp;gt; $grades{$b};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;# Help sort a
hash by the hash &#39;value&#39;, not the &#39;key&#39;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;# Values are
returned in descending numeric order&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;# (highest to
lowest).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;sub
hashValueDescendingNum {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$grades{$b}
&amp;lt;=&amp;gt; $grades{$a};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;%grades = (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;student1
=&amp;gt; 90,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;student2
=&amp;gt; 75,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;student3
=&amp;gt; 96,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;student4
=&amp;gt; 55,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;student5
=&amp;gt; 76,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;\n\tGRADES IN ASCENDING NUMERIC ORDER:\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $key
(sort hashValueAscendingNum (keys(%grades))) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;\t\t$grades{$key} \t\t $key\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;\n\tGRADES IN DESCENDING NUMERIC ORDER:\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach $key
(sort hashValueDescendingNum (keys(%grades))) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;\t\t$grades{$key} \t\t $key\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How to read
file into hash array ?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;open(IN,
&quot;&amp;lt;name_file&quot;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;or die
&quot;Couldn&#39;t open file for processing: $!&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;while
(&amp;lt;IN&amp;gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;chomp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$hash_table{$_}
= 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;close IN;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$_ = $hash_table{$_}\n&quot; foreach keys %hash_table;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do you
find the length of an array?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$@array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What value is
returned by a lone `return;&#39; statement?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The undefined
value in scalar context, and the empty list value () in list context.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;This way
functions that wish to return failure can just use a simple return without
worrying about the context in which they were called.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What&#39;s the
difference between /^Foo/s and /^Foo/?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The second
would match Foo other than at the start of the record if $* were set.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The
deprecated $* flag does double duty, filling the roles of both /s and /m. By
using /s, you suppress any settings of that spooky variable, and force your
carets and dollars to match only at the ends of the string and not at ends of
line as well -- just as they would if $* weren&#39;t set at all.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Does Perl
have reference type?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Yes. Perl can
make a scalar or hash type reference by using backslash operator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;For example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$str =
&quot;here we go&quot;; # a scalar variable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$strref =
\$str; # a reference to a scalar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@array =
(1..10); # an array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$arrayref =
\@array; # a reference to an array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Note that the
reference itself is a scalar.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How to
dereference a reference?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;There are a
number of ways to dereference a reference.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Using two
dollar signs to dereference a scalar.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$original =
$$strref;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Using @ sign
to dereference an array.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@list = @$arrayref;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Similar for
hashes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What does
length(%HASH) produce if you have thirty-seven random keys in a newly created
hash?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;length() is a
built-in prototyped as sub length($), and a scalar prototype silently changes
aggregates into radically different forms. The scalar sense of a hash is false
(0) if it&#39;s empty, otherwise it&#39;s a string representing the fullness of the
buckets, like &quot;18/32&quot; or &quot;39/64&quot;. The length of that string
is likely to be 5. Likewise, `length(@a)&#39; would be 2 if there were 37 elements
in @a.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;If EXPR is an
arbitrary expression, what is the difference between $Foo::{EXPR} and
*{&quot;Foo::&quot;.EXPR}?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The second is
disallowed under `use strict &quot;refs&quot;&#39;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Dereferencing
a string with *{&quot;STR&quot;} is disallowed under the refs stricture,
although *{STR} would not be. This is similar in spirit to the way
${&quot;STR&quot;} is always the symbol table variable, while ${STR} may be the
lexical variable. If it&#39;s not a bareword, you&#39;re playing with the symbol table
in a particular dynamic fashion.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I do
&amp;lt; fill-in-the-blank &amp;gt; for each element in an array?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl
-w&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@homeRunHitters
= (&#39;McGwire&#39;, &#39;Sosa&#39;, &#39;Maris&#39;, &#39;Ruth&#39;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach
(@homeRunHitters) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$_ hit a lot of home runs in one year\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I
replace every &amp;lt;TAB&amp;gt; character in a file with a comma?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;perl -pi.bak
-e &#39;s/\t/,/g&#39; myfile.txt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What is the
easiest way to download the contents of a URL with Perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Once you have
the libwww-perl library, LWP.pm installed, the code is this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;use
LWP::Simple;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$url = get
&#39;http://www.websitename.com/&#39;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How to
concatenate strings with Perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Method #1 -
using Perl&#39;s dot operator:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$name =
&#39;checkbook&#39;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$filename =
&quot;/tmp/&quot; . $name . &quot;.tmp&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Method #2 -
using Perl&#39;s join function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$name =
&quot;checkbook&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$filename =
join &quot;&quot;, &quot;/tmp/&quot;, $name, &quot;.tmp&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Method #3 -
usual way of concatenating strings&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$filename =
&quot;/tmp/${name}.tmp&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I read
command-line arguments with Perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;With Perl,
command-line arguments are stored in the array named @ARGV.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$ARGV[0]
contains the first argument, $ARGV[1] contains the second argument, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$#ARGV is the
subscript of the last element of the @ARGV array, so the number of arguments on
the command line is $#ARGV + 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Here&#39;s a
simple program:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;#!/usr/bin/perl&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$numArgs =
$#ARGV + 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;thanks, you gave me $numArgs command-line arguments.\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach
$argnum (0 .. $#ARGV) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$ARGV[$argnum]\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;When would
`local $_&#39; in a function ruin your day?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;When your
caller was in the middle for a while(m//g) loop&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The /g state
on a global variable is not protected by running local on it. That&#39;ll teach you
to stop using locals. Too bad $_ can&#39;t be the target of a my() -- yet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;What happens
to objects lost in &quot;unreachable&quot; memory, such as the object returned
by Ob-&amp;gt;new() in `{ my $ap; $ap = [ Ob-&amp;gt;new(), \$ap ]; }&#39; ?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Their destructors
are called when that interpreter thread shuts down.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;When the
interpreter exits, it first does an exhaustive search looking for anything that
it allocated. This allows Perl to be used in embedded and multithreaded
applications safely, and furthermore guarantees correctness of object code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Assume that
$ref refers to a scalar, an array, a hash or to some nested data structure.
Explain the following statements:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$$ref; #
returns a scalar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$$ref[0]; #
returns the first element of that array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$ref- &amp;gt;
[0]; # returns the first element of that array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@$ref; #
returns the contents of that array, or number of elements, in scalar context&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$&amp;amp;$ref; #
returns the last index in that array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;$ref- &amp;gt;
[0][5]; # returns the sixth element in the first row&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@{$ref- &amp;gt;
{key}} # returns the contents of the array that is the value of the key
&quot;key&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do you
match one letter in the current locale?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;/[^\W_\d]/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;We don&#39;t have
full POSIX regexps, so you can&#39;t get at the isalpha() &amp;lt;ctype.h&amp;gt; macro
save indirectly. You ask for one byte which is neither a non-alphanumunder, nor
an under, nor a numeric. That leaves just the alphas, which is what you want.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do I
print the entire contents of an array with Perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;To answer
this question, we first need a sample array. Let&#39;s assume that you have an
array that contains the name of baseball teams, like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@teams =
(&#39;cubs&#39;, &#39;reds&#39;, &#39;yankees&#39;, &#39;dodgers&#39;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;If you just
want to print the array with the array members separated by blank spaces, you
can just print the array like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@teams =
(&#39;cubs&#39;, &#39;reds&#39;, &#39;yankees&#39;, &#39;dodgers&#39;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;@teams\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;But that&#39;s
not usually the case. More often, you want each element printed on a separate
line. To achieve this, you can use this code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;@teams =
(&#39;cubs&#39;, &#39;reds&#39;, &#39;yankees&#39;, &#39;dodgers&#39;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;foreach
(@teams) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;print
&quot;$_\n&quot;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl uses
single or double quotes to surround a zero or more characters. Are the single(&#39;
&#39;) or double quotes (&quot; &quot;) identical?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;They are not
identical. There are several differences between using single quotes and double
quotes for strings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;1. The
double-quoted string will perform variable interpolation on its contents. That
is, any variable references inside the quotes will be replaced by the actual
values.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;2. The
single-quoted string will print just like it is. It doesn&#39;t care the dollar
signs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;3. The
double-quoted string can contain the escape characters like newline, tab,
carraige return, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;4. The
single-quoted string can contain the escape sequences, like single quote,
backward slash, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How many ways
can we express string in Perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Many. For
example &#39;this is a string&#39; can be expressed in:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;&quot;this is
a string&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;qq/this is a
string like double-quoted string/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;qq^this is a
string like double-quoted string^&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;q/this is a
string/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;q&amp;amp;this is
a string&amp;amp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;q(this is a
string)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;How do you
give functions private variables that retain their values between calls?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Create a
scope surrounding that sub that contains lexicals.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Only lexical
variables are truly private, and they will persist even when their block exits
if something still cares about them. Thus:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;{ my $i = 0;
sub next_i { $i++ } sub last_i { --$i } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;creates two
functions that share a private variable. The $i variable will not be
deallocated when its block goes away because next_i and last_i need to be able
to access it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;1) What are
the two different types of data perl handles?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Perl handles
two types of data they are&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(i) Scalar
Variables and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(ii) Lists&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Scalar
variables hold a single data item whereas lists hold multiple data items.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;2) What are
scalar variables?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Scalar
variables are what many programming languages refer to as simple variables.
They hold a single data item, a number, a string, or a perl reference. Scalars
are called scalars to differentiate them from constructs that can hold more
than one item, like arrays.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;3) Explain
about lists?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;A list is a
construct that associates data elements together and you can specify a list by
enclosing those elements in parenthesis and separating them with commas. They
could themselves be arrays, hashes or even other lists. Lists do not have a
specific list data type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;4) Name all
the prefix dereferencer in perl?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The symbol
that starts all scalar variables is called a prefix dereferencer. The different
types of dereferencer are.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(i) $-Scalar
variables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(ii) %-Hash
variables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(iii)
@-arrays&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(iv)
&amp;amp;-subroutines&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(v) Type
globs-*myvar stands for @myvar, %myvar.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;5) Explain
about an ivalue?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;An ivalue is
an item that can serve as the target of an assignment. The term I value
originally meant a “left value”, which is to say a value that appears on the
left. An ivalue usually represents a data space in memory and you can store
data using the ivalues name. Any variable can serve as an ivalue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;6) How does a
“grep” function perform?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Grep returns
the number of lines the expression is true. Grep returns a sublist of a list
for which a specific criterion is true. This function often involves pattern
matching. It modifies the elements in the original list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;7) Explain
about Typeglobs?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Type globs
are another integral type in perl. A typeglob`s prefix derefrencer is *, which
is also the wild card character because you can use typeglobs to create an
alias for all types associated with a particular name. All kinds of
manipulations are possible with typeglobs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;8) Is there
any way to add two arrays together?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Of course you
can add two arrays together by using push function. The push function adds a
value or values to the end of an array. The push function pushes the values of
list onto the end of the array. Length of an array can be increased by the
length of list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;9) How to use
the command shift?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Shift array
function shifts off the first value of the array and returns it, thereby
shortening the array by one element and moving everything from one place to the
left. If you don’t specify an array to shift, shift uses @ ARGV, the array of
command line arguments passed to the script or the array named @-.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;10) What
exactly is grooving and shortening of the array?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;You can
change the number of elements in an array simply by changing the value of the
last index of/in the array $#array. In fact, if you simply refer to a non
existent element in an array perl extends the array as needed, creating new
elements. It also includes new elements in its array.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;11) What are
the three ways to empty an array?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The three
different ways to empty an array are as follows&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;1) You can
empty an array by setting its length to a negative number.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;2) Another
way of empting an array is to assign the null list ().&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;3) Try to
clear an array by setting it to undef, but be aware when you set to undef.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;12) How do
you work with array slices&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;An array
slice is a section of an array that acts like a list, and you indicate what
elements to put into the slice by using multiple array indexes in square
brackets. By specifying the range operator you can also specify a slice.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;13) What is
meant by splicing arrays explain in context of list and scalar.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Splicing an
array means adding elements from a list to that array, possibly replacing
elements now in the array. In list context, the splice function returns the elements
removed from the array. In scalar context, the splice function returns the last
element removed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;14) What are
the different types of perl operators?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;There are
four different types of perl operators they are&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(i) Unary
operator like the not operator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(ii) Binary
operator like the addition operator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(iii)
Tertiary operator like the conditional operator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(iv) List
operator like the print operator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;15) Which has
the highest precedence, List or Terms? Explain?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;Terms have
the highest precedence in perl. Terms include variables, quotes, expressions in
parenthesis etc. List operators have the same level of precedence as terms.
Specifically, these operators have very strong left word precedence.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;16) What is a
short circuit operator?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The C-Style
operator, ll, performs a logical (or) operation and you can use it to tie
logical clauses together, returning an overall value of true if either clause
is true. This operator is called a short-circuit operator because if the left
operand is true the right operand is not checked or evaluated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;17) What are
the different forms of goto in perl? Explain?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The three
forms of goto are as follows. They are&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(i) Goto
label&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(ii) Goto
name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;(iii) Goto
expr&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The first
form, goto LABEL, transfers execution to the statement labeled LABEL. The
second form, goto EXPR, expects EXPR to evaluate to a label. The last form goto
&amp;amp;name is used with subroutines. This goto statement is used only when there
is a necessity as it can create havoc in a program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;18) What are
the different types of eval statements?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;There are two
different types of eval statements they are eval EXPR and eval BLOCK. Eval EXPR
executes an expression and eval BLOCK executes BLOCK. Eval Block executes an
entire block, BLOCK. First one is used when you want your code passed in the expression
and the second one is used to parse the code in the block.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;19) Determine
the difference between my and local?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The
fundamental difference between my and local is that my creates a new variable,
whereas local saves a copy of an existing variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;20) Explain
about returning values from subroutines (functions)?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-size: 9.0pt; line-height: 115%;&quot;&gt;The return
value of the subroutine is the value of the last expression evaluated or you
can explicitly use a return statement to exit the subroutine specifying the
return value. That return value is evaluated in the appropriate content
depending on the content of the subroutine call.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asuddenhelp.blogspot.com/2013/11/perl-powerful-way-to-impress-while.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item></channel></rss>