要求:每行一个读入从键盘上输入的字符,然后再以相反的顺序打印出来。
#! /usr/bin/perl
print "please input characters,and use CTRL-D finish:\n";
chomp(@a=);
@b=reverse @a;
print "@b\n";
#! /usr/bin/perl
print "please input characters,and use CTRL-D finish:\n";
chomp(@a=);
@b=reverse @a;
print "@b\n";
0
写一个程序,读入一些数字(每行一个),直到文件结尾为止。然后根据每一个输入的数字,输出相对应的字符串。数组是给定的。
#! /bin/usr/perl -w
print "please input some numbers,and use CTRL+D finish:\n";
@name = qw(fred betty barney dino wilma pebbles bamm);
chomp(@number=);
print "@name\n";
foreach $i (@number) {
print "$name[$i-1]\n";
}
#! /bin/usr/perl -w
print "please input some numbers,and use CTRL+D finish:\n";
@name = qw(fred betty barney dino wilma pebbles bamm);
chomp(@number=
print "@name\n";
foreach $i (@number) {
print "$name[$i-1]\n";
}
0
写一个程序,读入一些数字(每行一个),直到文件结尾为止。然后按照ASCII码序输出所有字符。
#! /bin/usr/perl
chomp (@ch=);
print "@ch\n";
@ch2=sort @ch;
foreach (@ch2) {
print "$_\n";
}
#! /bin/usr/perl
chomp (@ch=
print "@ch\n";
@ch2=sort @ch;
foreach (@ch2) {
print "$_\n";
}
编辑回复