- 论坛徽章:
- 307
|
本帖最后由 sunzhiguolu 于 2016-12-27 15:26 编辑
回复 30# Windows19
- #!/usr/bin/perl
- use strict;
- use warnings;
- my ($NS, %hKeys) = (0, ());
- while (<>){
- print "|||$_" if ($. == 134084); # 这里加个断点
- if (@ARGV){
- next if (/\A\s*\z/);
- chomp;
- my $k = /\A\d/ ? 'N' : 'S';
- $hKeys{$k}{$_} = 1;
- next;
- }
- my $N = grep {$hKeys{'N'}{$_}} /\d+/g;
- my $S = grep {$hKeys{'S'}{$_}} /[a-z]+/gi;
- $NS++ if ($S and $N);
- $hKeys{'S'}{'!C'}++ if ($S);
- $hKeys{'N'}{'!C'}++ if ($N);
- }
- print join ("\n", "Num Str : $NS", "Strings : $hKeys{'S'}{'!C'}", "Numbers : $hKeys{'N'}{'!C'}");
|
|