• Perl语言入门:第六章习题:处理用户所指定的名字并汇报相应的姓。


    37 print " ----------------------------------_exercise_6_1-------------------------- ";
         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: ";
         47 $arrow_notation = ( chomp( $unpackeing = <STDIN>) );
         48 while ($unpackeing ne "exit") {
         49     print "Qurery result: ".$bless_function{$unpackeing}." ";
         50     print "Enter  name to query, enter "exit" to exit: ";
         51     chomp( $unpackeing = <STDIN>);
         52     print " ";
         53 }
         54 =head1
         55 $arrow_notation = "exit";
         56 while($arrow_notation ne "exit"){
         57     print "while loop. ";
         58 }
         59 =cut
         60 print " ----------------------------------_exercise_6_1-------------------------- ";

    输出:

    ----------------------------------_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 " ----------------------------------exists_hash_func_-------------------------- ";
          6 my %vertical_alignment;
          7 $vertical_alignment{"subscripting"} = 0;
          8 unless($vertical_alignment{"array_ref"}){
          9     print "0 ";
         10 }
         11 printf keys %vertical_alignment;
         12 if( exists $vertical_alignment{"array_ref"}){
         13     print " there is a library card for subscripting ";
         14 }
         15 else{
         16     print " no card. ";
         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 " there is a library card for subscripting ";
         23 }
         24 else{
         25     print " no card. ";
         26 }
         27 print " ----------------------------------exists_hash_func_-------------------------- ";
         28
         29 print " ----------------------------------delete_hash_func_-------------------------- ";
         30 my $anonymous = "subscripting";
         31 print $vertical_alignment{$anonymous}." ";
         32 delete $vertical_alignment{$anonymous};
         33 my @refer_to = keys %vertical_alignment;
         34 print "@refer_to";
         35 print " ----------------------------------delete_hash_func_-------------------------- ";
         36
         37 print " ----------------------------------_exercise_6_1-------------------------- ";
         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: ";
         47 $arrow_notation = ( chomp( $unpackeing = <STDIN>) );
         48 while ($unpackeing ne "exit") {
         49     print "Qurery result: ".$bless_function{$unpackeing}." ";
         50     print "Enter  name to query, enter "exit" to exit: ";
         51     chomp( $unpackeing = <STDIN>);
         52     print " ";
         53 }
         54 =head1
         55 $arrow_notation = "exit";
         56 while($arrow_notation ne "exit"){
         57     print "while loop. ";
         58 }
         59 =cut
         60 print " ----------------------------------_exercise_6_1-------------------------- ";

  • 相关阅读:
    spring boot 中使用redis session
    关于 JVM 内存的 N 个问题(转)
    在JAVA中记录日志的十个小建议
    spring boot jpa 多数据源配置
    python高性能web框架——Japronto
    毕业 3 年,为何技术能力相差越来越大?——转自阿里技术人生
    如何成为技术大牛——阿里CodeLife
    布式之数据库和缓存双写一致性方案解析(转)
    海量数据存储--分库分表策略详解 (转)
    Linux内核模块简单示例
  • 原文地址:https://www.cnblogs.com/books2read/p/11038261.html
Copyright © 2020-2023  润新知