1. Why do you write a program in Perl?

Ans : Easy to use and fast execution since perl script undergoes only two phases like compile phase and run phase.

2. What is the difference between chop & chomp functions in perl?

Ans : Chop removes last character.
Chomp removes new line character.

3. What is a hash?

Ans : It is array having attributes and
values.

4. How would you replace a char in string
and how do you store the number of replacements?

Ans : By using Translation operator
(tr///). Number of replacements can be obtained by assigning whole
expression to scalar variable.

5. How do you open a file for
writing?

Ans : open HANDLER, “<
filename” or die $!;

6. What is the difference between for
& foreach?

Ans : Only syntax differs.

7. What purpose does each of the following
serve: -w, strict, - T ?

Ans : List out the warnings if any in perl
program.

8. Explain the difference between use and
require?

Ans : "use" the controler will go to that
file during run time and come back to original program at the same
time if we consider the "require" the
         whole
file will get copied at the place where it is required.

9. Explain the difference between my and
local?

Ans : The variables declared with "my" can
live only within the block it was defined.
The variables declared with "local" can live within the block and
have its visibility in the functions called within that
block.

10. Which is the shebang in
perl?

Ans : #! /usr/bin/perl

11. Name the two phases of execution of
PERL program?

Ans : Compiler phase and Run
phase.

12. Which is the default variable in
PERL?

Ans : $_

13. How to check the syntax of the script
without executing the program?

Ans : #! /usr/bin/perl -c

14. How to get the version
PERL?

Ans : #! /usr/bin/perl -v

15. Which is the command used to change
the base of a number to another base?

Ans : sprintf

16. Which is the command used to remove
the new line character?

Ans : chomp();

17. How we can get ASCII value of
character?

Ans : Ord();

18. What is QW in list and why it is
used?

Ans : QW is quote word which mainly used
to avoid complexity in lists.

19. Give an example to show how the map
will be used for list?

Ans : print ( map lc ,A,B,C);

20. How array differs from list

Ans : Array is obtained by assigning list
to variable.

21. $#arrayname signifies

Ans : Last index of an array.

22. How we can get the size of an
array?

Ans : By assigning an array to any scalar
variables.

23. What are the functions of following
commands:
a. push
    
b. pop
    
c. shift
    
d. unshift

Ans : a. push = updates the values at the
end of an array.
b. pop = takes out the last element of an array.
c. shift =takes out the first element of an array.
d. unshift = updates the values at the beginning of an
array.

24. Give an example to show how splicing
will be done?

Ans : @num = (1,2,3,4,5);
@val = (6,7);
splice (@num ,4,0,@val);

25. How we can access the individual
values of hash?

Ans : Using {}

26. How to find the number of keys and
values in hash?

Ans : Using key words Keys and
Values.

27. Which is the function used to delete
the value of specified key?

Ans : undef

28. Which is the function to delete both
key and related value?

Ans : delete

29. What & specifies in
PERL?

Ans : Bitwise and

30. Which is the binding operater in
PERL?

Ans “ =~”

31. What are the functions of following
keywords
a. last    b.
next    c.
redo

Ans : a. last : used to exit from the
statement block.
b. next : used to skip the rest of the statements block and start
the next iteration.
c. redo : causes perl to restart the current statement
block.

32. List the regular expressions in
PERL?

Ans : m// , s/// ,tr///

33. How to pass an arguments to
subroutines?

Ans : Through variable @_.

34. Which is the default variable that
will be having argument value that is passed to
subroutine?

Ans : @_

35. What happens if a PATTERN is of null
string?

Ans : Last successfully executed regular
expression is used.

36. $value=~tr/SEARCHLIST/REPLACEMENTLIST/
in this expression what will be the variable $value
having?

Ans : SEARCHLIST

37. $value=~tr/SEARCHLIST/REPLACEMENTLIST/
how to find out the number of replacements in this
expression?

Ans : By assigning this expression to
another variable like
$count=($value=~tr/SEARCHLIST/REPLACEMENTLIST/)

38. How to complement the the search list
in Translation operator?

Ans : Using c modofier

39. How we can match the metacharacters in
pattern matching?

Ans : m/\metacharacter/

40. $var=~/\d/ What does it
match?

Ans : Matches any digit.

41. $var=~/\W/ it is equivalent to
a. [a-z]     b.
[a-zA-Z]     c.
[^0-9a-zA-Z]    
d. [0-9]

Ans : C

42. Which is the character that will be
used to match white space?

Ans : \s

43. What is the difference between \u and
\U?

Ans : \u changes next character to
uppercase.
\U changes following characters to uppercase.

44. What is the difference between
following expressions
$var=~/w[^aoi]nder/ &
$var=~/^w[aoi]nder/

Ans : first one will look for W followed
by something that is none of 'a' , 'o' , or 'i'
second one will matches at the begining of the line.

45. $txt=~/((T/N)est(ing|er))/) What are
the values of following variables
$txt ,
    $1
,
    $2
,
    $3

Ans : $1 = Testing, $2=T,
$3=ing

46. What are Quantifiers?

Ans : Quantifiers says how many times
something may match.

47. Which of the following matches zero or
more times
a. *     b. +
   c. ?
   d.
{}

Ans : a

47. How we can find out number of
arguments sent from command line?

Ans : Assigning @ARGV to any scalar
variables.

48. What are the difference in writing
script in C and PERL?

Ans : There we don't have a much
difference between PERL and shell script.
As of my knowledge both are good in there own way of work
environment.
As consern to speed & performance the PERL is a
head of shell.
---Perl is very good at text processing like we have regular
expressions.
---Shell scripts are mainly inteded for sys-admin tasks.

49. How we can use a Linux commands in
PERL?

Ans : By writing linux command in ``
operater.

50. Write a script to set an environment
variables?

Ans : $var = `setenv $VAR path
`;

51. How we can use foreach loop for
accessing the content of file?

Ans : foreach (< HANDLER
>) {
command1;
command2;
....... }

52. Write a script to list all unknown
directories of another directory?

Ans : chdir(dir name);
$var = `find . -type d -name “*” | tee list `;

perl FAQ(zz)的更多相关文章

  1. comp.lang.javascript FAQ [zz]

    comp.lang.javascript FAQ Version 32.2, Updated 2010-10-08, by Garrett Smith FAQ Notes 1 Meta-FAQ met ...

  2. verilog FAQ(zz)

    1. What is the race condition in verilog? Ans :The situation when two expressions are allowed to exe ...

  3. linux FAQ(zz)

    1.Which is the command used to find the available shells in your Operating System Linux ? Ans : $ech ...

  4. systemverilog FAQ(zz)

    1. What is clocking block? Ans: Clocking block can be declared using the keywords clocking and endcl ...

  5. [zz] pgpool-II load balancing from FAQ

    It seems my pgpool-II does not do load balancing. Why? First of all, pgpool-II' load balancing is &q ...

  6. Perl 语法 - 基础

    perl语言的核心是正则表达式,在文本处理上非常有优势,与python类似,但语法不同,perl的语法很灵活,用多了才会觉得好用. 常用知识点总结: perl语法类似于C语言(perl源于Unix), ...

  7. 查看perl及其模块

    Perl本身自带了很丰富的文档,如果把它们都打印出来,恐怕要耗费大量纸墨.我们试图清点过,但数到2000页左右的时候就数不清了(不用担心,我们用虚拟打印机计算页面数量,这样不会对树木造成威胁,挺环保的 ...

  8. perl 语法速查

    同时学perl.python和shell脚本会很容易将它们的语法搞混,本文主要是一个个人的总结,方便要用时的查询. perl基本语法.安装.帮助文档 文件头格式: #!/usr/bin/perl us ...

  9. perl 升级到5.20版本

    不建议先rm 先下载tar.gz ...然後手动安装..default 安装到/usr/local/目录下.. 然後修改/usr/bin/perl的symbolic link到/usr/local/b ...

随机推荐

  1. error LNK2019: unresolved external symbol 的一个解决方法

    在VS2010中使用opencv时,有时会出现如下类似的连接错误: 解决方法:根据头文件手动指定lib文件 #ifdef _DEBUG #pragma comment(lib,"*.lib& ...

  2. C++标准库之tuple

    构造 构造函数 tuple的构造函数很普通,没啥说的. default (1) constexpr tuple();默认构造函数 copy / move (2) tuple (const tuple& ...

  3. 通过 append() 和 prepend() 方法添加若干新元素

    在上面的例子中,我们只在被选元素的开头/结尾插入文本/HTML. 不过,append() 和 prepend() 方法能够通过参数接收无限数量的新元素.可以通过 jQuery 来生成文本/HTML(就 ...

  4. WPF数据模板样式选择器

    在使用数据模板样式选择器时,不能设置ItemContainerStyle的属性值,如果设置了该值,那么数据模板样式选择器会失去作用. 在使用数据模板样式选择器时,首先要创建数据模板样式选择器对象,此对 ...

  5. dll 在进程中怎么区分的

    平时一直没想过这个问题,今天在测试输入法注入的时候才发现windows下dll在进程中是以名字区分的,即使是完全一模一样的DLL. 具体详情,容我慢禀 :   需求是这样的,只能含有一个a.DLL,这 ...

  6. FFmpeg总结(六)AV系列结构体之AVPacket

    AVPacket位置:libavcodec/avcodec.h下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGVqanVubGlu/font/5a6 ...

  7. JAVA学习第六十三课 — 关于client服务端 &amp;&amp; URL类 &amp; URLConnection

    常见的client和服务端 client:       浏览器:IE:弹窗体,猎豹:弹窗体.多标签,争强效果 服务端:       server:TomCat:1.处理请求 2.给予应答 想让TomC ...

  8. PHPStorm2017去掉参数提示 parameter name hints

    JetBrains 的各种语言的 IDE 都灰常灰常好用, 个个都是神器, PHPStorm 作为PHP开发的神器也不必多说了 今天升级到 PHPStorm 2017.1 发现增加了好些新功能, 有个 ...

  9. 转:: 刺鸟:用python来开发webgame服务端(5)

    来源:http://ciniao.me/article.php?id=19 --------------- 刺鸟原创文章,转载请注明出处    在前面的文章中,我们已经开始了不少逻辑功能的开发,在这期 ...

  10. IOS时间与日期处理

    本文转载至 http://blog.sina.com.cn/s/blog_9cd1705d0102v5x4.html   主要有以下类: NSDate -- 表示一个绝对的时间点NSTimeZone ...