perl 期末考试题.docx
- 文档编号:24022968
- 上传时间:2023-05-23
- 格式:DOCX
- 页数:27
- 大小:23.28KB
perl 期末考试题.docx
《perl 期末考试题.docx》由会员分享,可在线阅读,更多相关《perl 期末考试题.docx(27页珍藏版)》请在冰豆网上搜索。
perl期末考试题
PERL复习题
一、选择题B
1.WhatisthesimplesttypeofdatathatPerlcanworkwith?
Aelement
Bscalar
Cvector
Dcomponent
2.Whichoperatorcanbeusedtotakethebottomitemfromanarray?
Apop
Bpush
Cpull
Dplant
3.Whichoperatorisusedtoarrangeitemsincharacterorder?
Aascend
Bsort
Carrange
Ddescend
4.Ratherthanusingprint,whatisoftenusedinPerlwhenformattingisimportant?
Aprintf
Bformat
Calign
Dshow
5.WhichmodifiercanbeusedwhenmatchinginPerltoignorecase?
As
Bv
Ci
Dc
6.Whichoperatorcanbeusedtobreakupastringintomorethanonepartbasedupona
separator?
Achop
Bsplit
Cdivide
Dparse
7.WhatoptiondoyouusewhenstartingPerltotellittoruninwarningmode?
__________
(Fillintheblank.)
8.Whichcontrolstructurecanbeusedtoexecuteonlyaconditionisfalse?
Auntil
Bunless
Cwhile
Dwithout
9.WhichofthefollowingcommandsshouldbeusedtoopenafilehandlenamedKARENtoan
existingfilenamedsw?
AopenKAREN“>sw”;BopenKAREN,“>sw”;
Copen“sw”KAREN;
Dopen“>sw”,KAREN;
10.WithinPerl,whichoperatorisusedtochangetheworkingdirectory?
Acd
Bchdir
Cpwd
Dwd
11.Whichoperatorcanbeusedtoaccessthefirstiteminanarray?
Ashift
Bstart
Cright$
Dleft$
12.Withinaloop,whichoperatorimmediatelyendsexecutionoftheloop?
Anext
Blast
Credo
Dleave
13.Whichfunctioncanbeusedtomakesureyourprogramexitswithanonzerostatusevenif
thereastandarderror?
Ahash
Bnoexit
Cnozero
Ddie
14.Whichofthefollowingoperatorsworkmostlikesimplesearching/patternmatching?
A/f
B/g
Cs///
Dm//
15.WhichkeywordisusedinPerltodefineasubroutine?
Abranch
Bsub
Csplit
Dmake
16.YouwanttoclosethedirectoryhandleEVAN.Whichofthefollowingshouldyouuseto
accomplishthis?
AcloseEVAN;
BclosedirEVAN;
Cclose_directoryEVAN;
Dnoneoftheabove
17.Whichofthefollowinglinesofcodeaccomplishesthesamethingas$price=$price+9;?
A$price+9;
B$price=+9;
C$price+=9;D9+$price
18.Whatvaluedovariableshavebeforetheyarefirstassigned?
Aundef
Bnull
C0
Dnil
19.WhichPerlfunctioncanbeusedtolaunchachildprocesstorunaprogram?
Asplit
Bspin
Cfork
Dsystem
20.WhichPerlfunctioncanbeusedtoidentifythefirstfoundoccurrenceofasubstring?
Afind
Bindex
Clocate
Dallocate
21.Whichcontrolstructurecanbeusedtoloopaslongasaconditionalexpressionreturnstrue?
Auntil
Bunless
Cwhile
Dwithout
22.Whichoperatorcanbeusedtocreateprivatevariableswithinasubroutine?
Anative
Blimited
Cmy
Dregional
23.Whichofthefollowingoperatorsisusedtoreturnavalueinasubroutine?
Areturn
Bsend
Cgive
Dshow
24.Yourscripthasjustreadinavariablefromthekeyboardandyouwanttostripthatvariableof
thenewlinecharacterthatcamein.Whatoperatorshouldyouusetoperformthisoperation?
Atidy
Btrim
Cchomp
Dslim
25.WhatisthedefaultsortorderinPerl?
Aalphabetic
Bnumeric
CASCII
Dnoneoftheabove
26.Withinaloop,whichoperatorjumpstotheendoftheloopbutdoesnotexittheloop?
AnextBlast
Credo
Dleave
27.Whichofthefollowingshouldbeusedtoprintvaluesinanarraythatdonotcontain
newlinesandaddthemtotheendofeachentry?
Aprint@array;
Bprint@array\n;
Cprint“@array\n”;
Dprint“$@array\\”;
28.Whichstringcomparisonoperatorwouldbeequivalenttothenumeric>operator?
Ane
Beq
Cge
Dgt
29.Whichfunctioncanbethoughtofastheoppositeofsplit?
Alink
Bjoin
Cunite
Dbond
30.Whichoperatorcanbeusedtoaddanitemtothebottomofanarray?
Apop
Bpush
Cpull
Dplant
31.WhichofthefollowingmathematicaloperationshasthehighestprecedenceinPerl?
A**
B++
C+
D-
32.以下哪一个字符串直接量的定义方式是错误的()
(1)'thankyou'
(2)""
(3)"a"friend"ofyours"
(4)"a\"friend\"ofyours"
33.以下哪一条语句是错误的()
(1)$_='helloworld';
(2)$a='helloworld';
(3)my$b,$a='helloworld';
(4)my($a,$b)=(0,'helloworld');
34.要使下面的程序正常运行,while后的表达式应选()。
$a=0;$b=55;
while(表达式)
{
$a+=2;}
print"$a\n";
(1)$a=$b
(2)$a*$a<=$b
(3)$a!
=$b
(4)$b==0
35.在Perl及其它程序设计语言中,数据是由()。
(1)变量来表示的。
(2)运算符来表示的。
(3)变量的值来表示的。
(4)运算符的值来表示的。
36.@array是一个数组变量,语句print@array;输出的是:
()
(1)数组的各个元素。
(2)数组的大小。
(3)数组的第一个元素。
(4)什么都不输出。
37.语句$a=@array;执行后,变量$a的值是()。
(1)数组@array的第一个元素的值。
(2)数组@array的大小。
(3)此语句语法是错的。
(4)未定义。
38.以下是用递归子程序求45的3次方,if后的表达式应该是()
subpower
{
($m,$n)=@_;
$n>=1||die'error!
';
return($m)if(表达式);
return($m*power($m,$n-1));
}
printpower(45,3);
(1)$n==1
(2)$n<0
(3)$n>=1
(4)$n!
=0
39.如要在子程序中接受两个作为参数的数组,则()
(1)子程序用一个二维数组作形参。
(2)子程序用两个数组作形参。
(3)子程序用两个引用作形参。
(4)子程序不能被实现。
40.以下程序表达式1处将创建一个对包含命令行参数的数组@ARGV的引用
$point,表达式1处应为()
#!
/usr/contrib/bin/perl-w
1:
表达式1
2:
print"ARGV=",join(",",表达式2),"\n";
(1)my$point=@ARGV;
(2)my$point={@ARGV};
(3)my$point=ARGV;
(4)my$point=\@ARGV;
41.上题的程序表达式2处应为()
(1)@$point
(2)$point
(3)@point
(4)\@point
42.模式/[^\d^-]/能匹配下面哪个字符串?
()
(1)-10
(2)200
(3)abc123
(4)#%@
43.以下哪个程序段能够显示哈希结构%abcd中所有的元素?
()
(1)foreach$Var(keys%abcd)
{
print“$Var\n”;
}
(2)for($I=0;$I<%abcd;$I++)
{
print“$%abcd{$I}\n”;
}
(3)while($Var(keys%abcd))
{
print“$Var\n”;
}
(4)printjoin(„\n‟,%abcd);
44.以下程序执行后,变量$count的值是()
$Str=‟helloworld!
‟;
$count=0;
while($Str=~m/(\w+)/g)
{
$count++;
}
(1)1
(2)2
(3)3
(4)12
45.以下程序的作用是()
open(MYFILE,"temp.txt");
while(
while(/(\w)/g){
$seen{$1}++;}
}
foreach$word(keys%seen)
{
print"$seen{$word}$word\n";
}
close(MYFILE);
(1)删除文件temp.txt中所有单词字符。
(2)统计temp.txt中各单词字符的出现频率。
(3)错误的程序。
(4)统计temp.txt中单词字符的总数。
46.下面程序产生的结果如何?
()
$s="abcdefghi";
while($s=~/(\w+)/g){
print"$1";
}
A:
abcdefghiB:
abcabcabc
C:
defdefdefD:
没有正确答案
47.下面程序产生的结果如何?
()
$s="abcdefghi";
while($s=~/(\w+)/){
print"$1";
}
A:
abcdefghiB:
abcabcabc
C:
defdefdefD:
没有正确答案
48.下面程序产生的结果是()
$s="BillyBobDaisy";
print"$1"while$s=~/(B\w+)/g;
print$1if$s=~/(\w+i\w+)/g;
ABillyBobBBillyBob
BillyDaisy
CBillyBobD上述选项均不对
Bob
49.下面程序产生的结果是()
$s="BillyBobDaisy";
print"$1"while$s=~/(B\w+)/gc;
print$1if$s=~/(\w+i\w+)/g;
ABillyBobBBillyBob
BillyDaisyCBillyBobD上述选项均不对
Bob
$seq=GATAGATAGATACCGCGGTAACAC;
($match)=$seq=~/(GATA)+/;
50.$match值为:
()
AGATABGATAGATAGATA
CnullD以上选项均不对
$seq=GATAGATAGATACCGCGGTAACAC;
($match)=$seq=~/((GATA)+)/;
51.$match值为:
()
AGATABGATAGATAGATA
CnullD以上选项均不对
@a=(0);
52.if(@a)中的表达式返回的是()
A:
TrueB:
False
C:
不一定
$a=“0”;
$b=0;
53.if($a)和if($b)中的表达式返回值分别为()
A:
TFB:
TT
C:
FFD:
FT
$a=1;
if($a=0){
print“Numberis$a“;
}else{
print“Numberisnot$a”;
}
54.程序运行结果是()
A:
Numberis0B:
Numberisnot0
C:
Numberis1D:
Numberisnot1
$a=1;
if($a==0){
print“Numberis$a“;
}else{
print“Numberisnot$a”;}
55.程序运行结果是()
A:
Numberis0B:
Numberisnot0
C:
Numberis1D:
Numberisnot1
56.whichcommandremovesallsubdirectoriesin/tmp,regardlessofwhethertheyare
non-existentorinuse?
a.del/tmp/*
b.m-rf/tmp
c.rm-ra/tmp/*
d.rm-rf/tmp/*
e.delete/tmp/*,*
57.youhavethefollowingfile:
-rwxrwxr-x1fooroot0feb2307:
48/bin/foo
whichofthefollowingcommandswillchangetheownerofthefile/bin/foofromthefoouserto
thebaruserwithoutaffectinggroupownership?
a.chown/bin/foobar
b.chownbar/bin/foo
c.chownbar.foo/bin/foo
d.chown.foo.bar/bin/foo
58.yourunmaskissetto002.ifyoucreateanewfile,whatwillthepermissionofthenewfile
be?
a.–rw-rw-r--
b.rwxrwx-w-
c.------w-
d.rwxrwxr-x
59.whichofthefollowingfileshasthecorrectpermissions?
a.-rw--w--w-1rootroot369dec2222:
38/etc/shadow
b.-rwxrw-rw-1rootroot369dec2222:
38/etc/shadow
c.-rw-r--r--1rootroot369dec2222:
38/etc/shadow
d.–r--------1rootroot369dec2222:
38/ect/shadow
60.linuxisa(n)_________operatingsystem,meaningthesourcecodeisfreelyavailable.
a.opensourced
b.userlicensed
c.closedsource
d.openbinary
61.whichofthefollowingcommandscanbeusedtoextractatarfile?
a.tar-vf
b.tar-xvfc.tar-e
d.tar–v
62.LINUX有三个查看文件的命令,如果我们希望在查看文件内容过程中用光标可以上下
移动来查看文件内容,则请从下面的命令中选出符合要求的那一个。
()
A.catB.moreC.less
63.LINUX系统提供了一些网络测试命令,当我们与某远程网络连接不上时,就需要跟踪
路由查看,以便了解在网络的什么位置出现了问题,请从下面的命令中选出满足该目的
的命令。
()
A.pingB.ifconfigC.tracerouteD.netstat
64.以下哪一个字符串直接量的定义方式是错误的()
(1)'thankyou'
(2)""
(3)"a"friend"ofyours"
(4)"a\"friend\"ofyours"
65.以下哪一条语句是错误的()
(1)$_='helloworld';
(2)$a='helloworld';
(3)my$b,$a='helloworld';
(4)my($a,$b)=(0,'helloworld');
66.要使下面的程序正常运行,while后的表达式应选()。
$a=0;$b=55;
while(表达式)
{
$a+=2;
}
print"$a\n";
(1)$a=$b
(2)$a*$a<=$b
(3)$a!
=$b
(4)$b==0
67.在Perl及其它程序设计语言中,数据是由()。
(1)变量来表示的。
(2)运算符来表示的。
(3)变量的值来表示的。
(4)运算符的值来表示的。
68.@array是一个数组变量,语句print@array;输出的是:
()
(1)数组的各个元素。
(2)数组的大小。
(3)数组的第一个元素。
(4)什么都不输出。
69.语句$a=@array;执行后,变量$a的值是()。
(1)数组@array的第一个元素的值。
(2)数组@array的大小。
(3)此语句语法是错的。
(4)未定义。
70.以下是用递归子程序求45的3次方,if后的表达式应该是()
subpower
{
($m,$n)=@
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- perl 期末考试题 期末 考试题