分类: Python/Ruby
2011-11-01 13:26:45
#!/usr/bin/perl
# Author: lyg
# Date & Time: 2011-08-26 18:31:02
# Description:
print "pls input string:\n";
chomp(@string=
print "pls input string's length:\n";
chomp($length=
if ( $length !~ /[0-9]/) {
print "string's length must be a number!\n";
}
print "123456789012345678901234567890\n";
foreach (@string) {
printf "%" . $length . "s\n",$_;
}
重点在于if ( $length !~ /[0-9]/)
判断$length 是否为一个整数