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语言入门:第六章习题:处理用户所指定的名字并汇报相应的姓。的更多相关文章

  1. C 语言入门---第六章 C语言数组

    数组就是一些列具有相同类型的数据的集合,这些数据在内存中一次挨着存放,彼此之间没有缝隙. 我们可以将二维数组看作一个Excel表格,有行有列,length1 表示行数,length2 表示列数,要在二 ...

  2. Perl语言入门:第九章 使用正则表达式处理文本 示例程序和代码

    #! /usr/bin/perl use strict; use warnings; print "\n----------------------------------_substitu ...

  3. Perl语言入门: 斜线不是元字符,所以在不作为分隔符时不需要加上反斜线。

    Perl语言入门: 斜线不是元字符,所以在不作为分隔符时不需要加上反斜线.

  4. Perl语言入门(中文版)(第6版) 东南大学出版社

    第一章简介 问题与答案 这本书适合你吗? 为何有这么多的脚注? 关于习题和解答? 习题前标的数字是什么意思? 如果我是Perl讲师? “Perl”这个词表示什么意思? Larry为什么要创造Perl? ...

  5. Perl语言入门14-17

    ---------第十四章 字符串与排序------------------- index查找子字符串 my $stuff = "howdy world!"; my $where ...

  6. Perl语言入门

    Perl 是 Practical Extraction and Report Language 的缩写,可翻译为 "实用报表提取语言". Perl语法基础: (1)Perl程序由声 ...

  7. Go语言入门系列(六)之再探函数

    Go语言入门系列前面的文章: Go语言入门系列(三)之数组和切片 Go语言入门系列(四)之map的使用 Go语言入门系列(五)之指针和结构体的使用 在Go语言入门系列(二)之基础语法总结这篇文章中已经 ...

  8. Perl语言入门:第七章习题:输出文件中包含一个大写字母的所有行,不输出一行的内容全是大写的

    文件内容: bash-2.03$ cat file_4_ex_ch7.txt anonymous attribute demolition grammar rules indices refernce ...

  9. 网易云课堂_程序设计入门-C语言_第六章:数组_2鞍点

    2 鞍点(5分) 题目内容: 给定一个n*n矩阵A.矩阵A的鞍点是一个位置(i,j),在该位置上的元素是第i行上的最大数,第j列上的最小数.一个矩阵A也可能没有鞍点. 你的任务是找出A的鞍点. 输入格 ...

随机推荐

  1. Servlet单例非安全解析

    Servlet容器默认是采用单实例多线程的方式处理多个请求 Servlet容器<Web容器<应用服务器?apache<tomcat<websphere Servlet不是线程安 ...

  2. 基于COCHONUT做和弦识别

    论文为:COCHONUT: Recognizing Complex Chords From MIDI Guitar Sequences 出处:international symposium/confe ...

  3. Linux 常用命令十四 killall和pkill

    用killall杀死所有同名的进程. wang@wang:~/workpalce/git$ ps -aux | grep vim wang pts/ S+ : : vim a wang pts/ S+ ...

  4. python 面向对象五 获取对象信息 type isinstance getattr setattr hasattr

    一.type()函数 判断基本数据类型可以直接写int,str等: >>> class Animal(object): ... pass ... >>> type( ...

  5. C# 读写text 详细讲解

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     & ...

  6. ssh 公钥登录远程主机 并禁止密码登录

    https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-centos7 如果在新的机器上,得先用密码登录一 ...

  7. redis相关配置

    redis相关配置1.yum 源码 rpm yum 快速,间接,高效,解决依赖关系,(自动安装到某个路径,不可控),通过yum安装的软件查询命令 rpm -ql nginx yum源的软件包可能版本非 ...

  8. [SHOI2002]取石子游戏之三

    Wythoff's Game,详解请见浅谈算法--博弈论中的例6 /*program from Wolfycz*/ #include<cmath> #include<cstdio&g ...

  9. _bzoj2038 [2009国家集训队]小Z的袜子(hose)【莫队】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 裸的莫队,注意要先移动右端点再移动左端点. #include <cstdio&g ...

  10. 51nod 1024 矩阵中不重复的元素

    1024 矩阵中不重复的元素  题目来源: Project Euler 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 一个m*n的矩阵. 该矩阵的 ...