您的位置:首页 > 其它

鼠标发展历史历程

2010-07-02 20:49 369 查看
Perl 字符串按照给定的长度分割并返回数组

 

sub splitStr {
my ( $strtmp, $length ) = @_;
my $strLength = length $strtmp;
my @results;
for ( my $i = 0 ; $i < $strLength ; $i += $length ) {
#if length reach the bound , just resturn the left ones
if ( $strLength < ( $i + $length ) ) {
push @results, substr( $strtmp, $i );
}
else {
push @results, substr( $strtmp, $i, $length );
}
}
return \@results;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: