perl 题目

本文介绍了Perl编程语言中数组与列表的区别、use strict与use warnings的作用、while与foreach的不同用法,以及如何查看引用类型等实用技巧。同时探讨了Perl语言的一些高级特性,如变量作用域、模块使用等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 数组和列表量的区别

  在标量环境下,数组返回数组长度。而列表值返回最后一个值。

 列表(),会将小括号的东西放到堆栈中,使用时一个个弹出。

2. use strict  use warnings 的作用

use strict帮你寻找因为错误拼写造成的错误,解决命名变量问题。use strict 迫使你把变量的范围缩到最小,使你不必担心同名变量在程序的其它部份发生不良作用。

use warnings;的话perl在编译的时候会将警告信息打印出来,否则不打印。

3. while(<>) forreach(<>)的区别?

While(<>)一次处理一行输入。

Foreach(<>) 一次处理全部输入。

4. 怎么查看引用的类型?

 使用ref函数。Ref函数会先判读标量变量是否包含一个引用,然后再判读指向什么类型的引用。

$a = 10;        ## ref($a) 返回false

$ra = \$a;      ##ref($ra) == ‘SCALAR’

$rarray = [‘a’,’b’,’c’];    ##ref($array) == ‘ARRAY’;

$rhash = {‘a’,’A’,’b’,’B’,’c’,’C’};  ##ref($rhash) == ‘HASH’



What arguments do you frequently use for the Perl interpreter and what do they mean? 
What does the command ‘use strict’ do and why should you use it? 
What do the symbols $ @ and % mean when prefixing a variable? 
What elements of the Perl language could you use to structure your code to allow for maximum re-use and maximum readability? 
What are the characteristics of a project that is well suited to Perl? 
Why do you program in Perl? 
Explain the difference between my and local. 
Explain the difference between use and require. 
What’s your favorite module and why? 
What is a hash? 
Write a simple (common) regular expression to match an IP address, e-mail address, city-state-zipcode combination. 
What purpose does each of the following serve: -w, strict, -T ? 
What is the difference between for & foreach, exec & system? 
Where do you go for Perl help? 
Name an instance where you used a CPAN module. 
How do you open a file for writing? 
How would you replace a char in string and how do you store the number of replacements? 
When would you not use Perl for a project?

5  perl 中引号特殊符号

  1. q  是单引号  
  2. qq 是双引号  
  3. qw 单词列表引号  
  4. qr 正则表达式引号  
  5. qx 反引号  
  6. 其中qq,qw又较为常用


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值