习题:处理用户所指定的名字并汇报相应的姓。
Posted books2read
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了习题:处理用户所指定的名字并汇报相应的姓。相关的知识,希望对你有一定的参考价值。
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";
以上是关于习题:处理用户所指定的名字并汇报相应的姓。的主要内容,如果未能解决你的问题,请参考以下文章