常用字符串操作
手软脚软
这个作者很懒,什么都没留下…
展开
-
join使用
// 在日常开发中,经常会碰到需要将多个字符串以某些相同的分隔字符串连接起来的情形 // "select * from t where name in ('a', 'b', .. , 'z')"中的"', '" // "insert into t(name) values ('a'), ('b')"中的 "'), ('" // ab a 中的 "" //原创 2013-03-01 23:04:59 · 292 阅读 · 0 评论 -
Perl的那些技巧:平均切割数组
有些时候需要将数组分成长度相同的多个子数组,比如批量查询数据库。 这时,我们可以用splice完成这个功能。代码如下: #!/usr/bin/env perl use strict; use warnings; my @chunks; my $size = 10; my @array = (1..100); push @chunks, [splice(@array, 0, $size)]原创 2013-11-30 11:42:12 · 1157 阅读 · 0 评论