之前写过perl的一个简单的程序。过了很久了,决定重新系统的开始学习一下perl。
1.
-
@lines = reverse (@lines = <STDIN>);
-
-
print "output is \n @lines"
2.
-
@names = qw(fred betty dino wilma pebbles bamm-bamm);
-
$number = $#names;
-
@inputs = <STDIN>;
-
foreach $index (@inputs) {
-
if ($index >= $number) {
-
print "invalid number $index";
-
exit;
-
}
-
}
-
-
foreach $index (@inputs) {
-
print "$names[$index] ";
-
}
-
print "\n"
3.
-
@names = sort(@names = <STDIN>);
-
chomp(@names);
-
print "show in one line \n@names\n";
-
-
print "show in one each line\n";
-
-
foreach $a (@names) {
-
print "$a\n";
-
}
阅读(776) | 评论(0) | 转发(0) |