- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2016-08-01 10:36 编辑
回复 10# sunzhiguolu
Would you like this way just to get the same hypen number
$ perl get-hyphen.pl FILE 2>report.txt
-hy
hu-
ju-li-
...
$ cat report.txt
1 -hy
1 hu-
1 ju-li-
-1 -vh--jfu---nc7ft----gf7d-----nvhg------
1 -hfy-mi8-
2 --bfhk--6dgt7--
3 hfyw5---9fjy6
4 hfydr----89ku7y5.
5 ctd-----hf.d76
6 ftsn------mc.d7
6 dg.d------7fb------hft5------
3 ---mdu.76dt
...
$ cat get-hyphen.pl
use strict;
use warnings;
sub get_hyphen{
local ($_) = @_;
return 0 if(!m/(-+)/g);
my $sLen = length($1);
while(m/(-+)/g){
return -1 if($sLen != length($1));
}
return $sLen;
}
while(<>){
my $sHyphen = get_hyphen($_);
print STDERR "$sHyphen $_";
if( 1 <= $sHyphen && $sHyphen <= 3){
print "$_";
}
}
|
评分
-
查看全部评分
|