elsif中确实缺一个"e"
1 #!/usr/bin/perl -w
2 $a = <STDIN>;
3 chop $a;
4 if (!$a)
5 {
6 print "The string is empty!";
7 }
8 elsif (length($a) == 1)
9 {
10 print "The string has one character!/n";
11 }
12 elsif (length($a) == 2)
13 {
14 print "The string has two characters!/n";
15 }
16 else
17 {
18 print "the string has many characters!/n";
19 }
1 #!/usr/bin/perl -w
2 $a = <STDIN>;
3 chop $a;
4 if (!$a)
5 {
6 print "The string is empty!";
7 }
8 elsif (length($a) == 1)
9 {
10 print "The string has one character!/n";
11 }
12 elsif (length($a) == 2)
13 {
14 print "The string has two characters!/n";
15 }
16 else
17 {
18 print "the string has many characters!/n";
19 }
本文介绍了一个Perl脚本,该脚本用于检查从标准输入读取的字符串的长度,并根据不同长度输出相应的信息。如果字符串为空,则输出提示信息;如果字符串长度为1或2,则分别输出特定信息;对于更长的字符串,则输出一般信息。
169

被折叠的 条评论
为什么被折叠?



