interview question

Basic

 

1. Which statement is wrong:

 

A.        $_= 'hello world';

 

B.        $a='hello world';

 

C.        my $b,$a='hello world';

 

D.       my ($a,$b)=(0,'hello world');

 

Item C: $b is empty and $a is ‘hello world’

All of items is correct in program syntax, and can run.

 

 

2. The expression should be (B), then the following code can run correctly:

 

$a=0;$b=55;

 

while (expression)

 

{

 

  $a+=2;

 

}

 

print "$a/n";

 

A.        $a = $b

 

B.        $a*$a <= $b

 

C.        $a != $b

 

D.       $b == 0

 

 

 

3. @array is an array variable, what is output of “print @array;” :A

 

A.        Each element of this array

 

B.        The size of this array

 

C.        The first element of this array

 

D.       Nothing

 

 

 

4. “$a = @array;”, what is value of $a: B

 

A.        The first element’s value of this array

 

B.        The size of this array

 

C.        This line code is wrong

 

D.       N/A

 

 

 

5. Which code snippet can print all elements in %abcd: B

 

A.    foreach $Var (keys %abcd)

 

   {

 

     print “$Var /n”;

 

   }

 

B.    for ($I=0;$I<%abcd;$I++)

 

   {

 

     print “$%abcd{$I} /n”;

 

   }

 

C.    while ($Var (keys %abcd))

 

   {

 

     print “$Var /n”;

 

   }

 

D.    print join(‘/n’,%abcd);

 

 

 

 

 


Advance:

 

6. After execute following code snippet, what is value of $count: B (match twice)

 

$Str=’hello world!’;

 

$count=0;

 

while ($Str=~m/(/w+)/g)

 

  {

 

    $count++;

 

  }

 

A.        1

 

B.        2

 

C.        3

 

D.       12

 

 

 

7. What is the result of $string? D

 

$string = "This string contains the number 25.11.";

$string =~ /-?(/d+)/.?(/d+)/;

 

A.        25.

 

B.        .11

 

C.        25.11

 

D.                             25.11.

I don’t know what is meaning of -, but perhaps the answer is D

 

 

8. What is meaning of following code snippet?

 

  open(MYFILE,"temp.txt");

 

  while (<MYFILE>) {

 

    while ( /(/w)/g ) {

 

      $seen{$1}++;

 

    }

 

  }

 

  foreach $word(keys %seen)

 

  {

 

    print "$seen{$word} $word/n";

 

  }

 

  close(MYFILE);

 

A.        Delete all words in temp.txt

 

B.        Calculate the frequency of each word in temp.txt

 

C.        Wrong code

 

D.       Calculate the sum of words in temp.txt

 

$1 is first variable of group match of perl, it match a char here.

 

9. In following code, expression#1 D let $point get the reference of @ARGV, expression#1  should be:

 

#!/usr/contrib/bin/perl -w

 

expression#1

print "ARGV = ", join(",", expression#2), "/n";

 

 

 

A.        my $point=@ARGV;

 

B.        my $point={@ARGV};

 

C.        my $point=ARGV;

 

D.       my $point=/@ARGV;

 

 

10. The expression#2 A should be:

 

A.        @$point

 

B.        $point

 

C.        @point

 

D.       /@point

 

 


NOTE: Answer of question 5  shoud be A 
20060519

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/new_life/archive/2006/05/17/743123.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值