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. JVM从理论到实践

    这里实践不是指动手写JVM,而是动手做实验,结合日常工作相关的部分,理论与实践结合从而对这块知识有更深入的认识. 随着Java10的到来,JVM这块也有不少调整改进,网上大部分内容都是过时或大部分开发 ...

  2. Linux CentOS 6.5中安装与配置Tomcat-8方法

    安装环境:CentOS-6.5 安装方式:源码安装 软件:apache-tomcat-8.0.0.RC3.tar.gz 下载地址:http://tomcat.apache.org/download-8 ...

  3. 使用 dynamic 标记解析JSON字符串(转)

    http://www.cnblogs.com/taotaodetuer/p/4171327.html string jsonStr = "{\"data\": {\&qu ...

  4. 洛谷P3569 [POI2014]KAR-Cards(线段树)

    传送门 蠢了…… 我们用线段树,记$w0$为该区间最左端取小值时,最右端最小能取大还是小还是无解,$w1$表示最左端取大值时,最右端最小能取大还是小还是无解 然后只要把交换看做修改就好了 这么说可能很 ...

  5. 创建swagger的springboot-stater,并在spring cloud zuul网关中引入

    Swagger 是一款RESTFUL接口的.基于YAML.JSON语言的文档在线自动生成.代码自动生成的工具. 通过在controller中添加注解,即可轻易实现代码文档化. Swagger提供ui界 ...

  6. 文件cp功能

    #include<stdio.h> #include<unistd.h> #include<fcntl.h> #include<string.h> in ...

  7. 洛谷 P1966 火柴排队

    题目描述 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度. 现在将每盒中的火柴各自排成一列, 同一列火柴的高度互不相同, 两列火柴之间的距离定义为:∑(ai​−bi​)2 其中ai​ 表示 ...

  8. [SRM625 Div1 Hard] Seatfriends

    题目链接:Portal Vjudge Solution 一开始拿到这一题Sb了,把空放到dp中一起考虑了,这样计数就变得很麻烦. 其实我们可以把空位拿出来,假设它是存在的,最后再放回去. 那么就可以钦 ...

  9. Chtholly Tree (珂朵莉树) ODT

    ODT,OldDriverTree,又名ChthollyTree" role="presentation" style="position: relative; ...

  10. 题解报告:hdu1202The calculation of GPA(算绩点问题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1202 Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对 ...