Perl语言入门:第六章习题:处理用户所指定的名字并汇报相应的姓。
37 print "\n----------------------------------_exercise_6_1--------------------------\n";
38 my %bless_function = ( #hash may be a lexical variable
39 "constructors" => "default_values",
40 "error_handling" => undef,
41 "existence_test_for" => "fat_commas",
42 "grep_func" => "labeled",
43 );
44 my $unpackeing;
45 my $arrow_notation = '';
46 print "Enter name to query, enter exit to exit:\n";
47 $arrow_notation = ( chomp( $unpackeing = <STDIN>) );
48 while ($unpackeing ne "exit") {
49 print "Qurery result: ".$bless_function{$unpackeing}."\n";
50 print "Enter name to query, enter "exit" to exit:\n";
51 chomp( $unpackeing = <STDIN>);
52 print "\n";
53 }
54 =head1
55 $arrow_notation = "exit";
56 while($arrow_notation ne "exit"){
57 print "while loop.\n";
58 }
59 =cut
60 print "\n----------------------------------_exercise_6_1--------------------------\n";
输出:
----------------------------------_exercise_6_1--------------------------
Enter name to query, enter exit to exit:
grep_func
1 grep_func
next line is while.
Qurery result: labeled
Enter name to query, enter exit to exit:
^C
第六章后半段练习代码:
bash-2.03$ vim hash_exists_del_func_exercise.pl
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
4
5 print "\n----------------------------------exists_hash_func_--------------------------\n";
6 my %vertical_alignment;
7 $vertical_alignment{"subscripting"} = 0;
8 unless($vertical_alignment{"array_ref"}){
9 print "0\n";
10 }
11 printf keys %vertical_alignment;
12 if( exists $vertical_alignment{"array_ref"}){
13 print "\nthere is a library card for subscripting\n";
14 }
15 else{
16 print "\nno card.\n";
17 }
18 $vertical_alignment{"array_ref"} = undef;
19 $vertical_alignment{"attr_demolition"} = "indices";
20 printf keys %vertical_alignment;
21 if( exists $vertical_alignment{"array_ref"}){
22 print "\nthere is a library card for subscripting\n";
23 }
24 else{
25 print "\nno card.\n";
26 }
27 print "\n----------------------------------exists_hash_func_--------------------------\n";
28
29 print "\n----------------------------------delete_hash_func_--------------------------\n";
30 my $anonymous = "subscripting";
31 print $vertical_alignment{$anonymous}."\n";
32 delete $vertical_alignment{$anonymous};
33 my @refer_to = keys %vertical_alignment;
34 print "@refer_to";
35 print "\n----------------------------------delete_hash_func_--------------------------\n";
36
37 print "\n----------------------------------_exercise_6_1--------------------------\n";
38 my %bless_function = ( #hash may be a lexical variable
39 "constructors" => "default_values",
40 "error_handling" => undef,
41 "existence_test_for" => "fat_commas",
42 "grep_func" => "labeled",
43 );
44 my $unpackeing;
45 my $arrow_notation = '';
46 print "Enter name to query, enter exit to exit:\n";
47 $arrow_notation = ( chomp( $unpackeing = <STDIN>) );
48 while ($unpackeing ne "exit") {
49 print "Qurery result: ".$bless_function{$unpackeing}."\n";
50 print "Enter name to query, enter "exit" to exit:\n";
51 chomp( $unpackeing = <STDIN>);
52 print "\n";
53 }
54 =head1
55 $arrow_notation = "exit";
56 while($arrow_notation ne "exit"){
57 print "while loop.\n";
58 }
59 =cut
60 print "\n----------------------------------_exercise_6_1--------------------------\n";
Perl语言入门:第六章习题:处理用户所指定的名字并汇报相应的姓。的更多相关文章
- C 语言入门---第六章 C语言数组
数组就是一些列具有相同类型的数据的集合,这些数据在内存中一次挨着存放,彼此之间没有缝隙. 我们可以将二维数组看作一个Excel表格,有行有列,length1 表示行数,length2 表示列数,要在二 ...
- Perl语言入门:第九章 使用正则表达式处理文本 示例程序和代码
#! /usr/bin/perl use strict; use warnings; print "\n----------------------------------_substitu ...
- Perl语言入门: 斜线不是元字符,所以在不作为分隔符时不需要加上反斜线。
Perl语言入门: 斜线不是元字符,所以在不作为分隔符时不需要加上反斜线.
- Perl语言入门(中文版)(第6版) 东南大学出版社
第一章简介 问题与答案 这本书适合你吗? 为何有这么多的脚注? 关于习题和解答? 习题前标的数字是什么意思? 如果我是Perl讲师? “Perl”这个词表示什么意思? Larry为什么要创造Perl? ...
- Perl语言入门14-17
---------第十四章 字符串与排序------------------- index查找子字符串 my $stuff = "howdy world!"; my $where ...
- Perl语言入门
Perl 是 Practical Extraction and Report Language 的缩写,可翻译为 "实用报表提取语言". Perl语法基础: (1)Perl程序由声 ...
- Go语言入门系列(六)之再探函数
Go语言入门系列前面的文章: Go语言入门系列(三)之数组和切片 Go语言入门系列(四)之map的使用 Go语言入门系列(五)之指针和结构体的使用 在Go语言入门系列(二)之基础语法总结这篇文章中已经 ...
- Perl语言入门:第七章习题:输出文件中包含一个大写字母的所有行,不输出一行的内容全是大写的
文件内容: bash-2.03$ cat file_4_ex_ch7.txt anonymous attribute demolition grammar rules indices refernce ...
- 网易云课堂_程序设计入门-C语言_第六章:数组_2鞍点
2 鞍点(5分) 题目内容: 给定一个n*n矩阵A.矩阵A的鞍点是一个位置(i,j),在该位置上的元素是第i行上的最大数,第j列上的最小数.一个矩阵A也可能没有鞍点. 你的任务是找出A的鞍点. 输入格 ...
随机推荐
- Linux共享内存(二)
Linux共享内存编程实例 原文链接:http://blog.csdn.net/pcliuguangtao/article/details/6526119 /*共享内存允许两个或多个进程进程共享同一块 ...
- nginx中查看关于php的配置和php-fpm的重启等操作
1.查看当前使用的php的配置信息 在php项目的根目录下新建findini.php文件,内容如下: <?php phpinfo(); ?> 然后在页面上访问就可以看到如下页面: 搜索Lo ...
- 【WIP】外汇与证券交易29个技术指标
创建: 2017/05/16 更新: 2017/05/30 更新: 2017/10/14 标题加上[WIP],增加创建时间 指标名称 函数原型(prototype) 参考与分析 (refer ...
- CI框架中一个类中调用另一个类中已经加载对象测试
controller.php <?php class CI_Controller { private static $instance; public function __construct( ...
- 关于kindle无法连接上wifi的问题
家里换了宽带以后我发现kindle无法链接上WiFi了. 原因可能是我家使用的WiFi网络是1-11之间的信道,也有可能是运营商的问题(由于我是软件开发,对硬件和网络并不是很清楚,只能大概估计一下). ...
- bzoj3316: JC loves Mkk(单调队列+分数规划)
Description Input 第1行,包含三个整数.n,L,R.第2行n个数,代表a[1..n]. Output 仅1行,表示询问答案.如果答案是整数,就输出整数:否则,输出既约分数“P/Q”来 ...
- gRPC入门
一.gRPC简介 在介绍gRPC之前先说一下RPC(Remote Procedure Call),也叫远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议.相比 ...
- _bzoj1009 [HNOI2008]GT考试【矩阵加速dp】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1009 比较不错的一道题,令f(i, j)表示考号匹配到i位,后j位为不吉利串的前j位,那么对 ...
- _bzoj1059 [ZJOI2007]矩阵游戏【二分图匹配】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1059 保存匈牙利模板. #include <cstdio> #include & ...
- _bzoj1031 [JSOI2007]字符加密Cipher【后缀数组】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1031 保存后缀数组模版. 其实如果数据范围小一点,或者空间限制再大一点,或者甚至只要字母表再 ...