perl实现大小写字母混排用于生成字典
发布时间:2020-12-15 23:51:37 所属栏目:大数据 来源:网络整理
导读:例如输入全小写abc,则能够生成abc,Abc,aBc,ABc,abC,AbC,aBC,ABC: #!/usr/bin/perl -w$abc='abc';while($abc){ print $abc.$/; $abc = jia1($abc);}sub jia1{ my ($words) = (@_); if($words =~ /^[A-Z]+$/){return 0} my @words_array = split('',$words);
例如输入全小写abc,则能够生成abc,Abc,aBc,ABc,abC,AbC,aBC,ABC: #!/usr/bin/perl -w $abc='abc'; while($abc){ print $abc.$/; $abc = jia1($abc); } sub jia1{ my ($words) = (@_); if($words =~ /^[A-Z]+$/){return 0} my @words_array = split('',$words); my $jinwei = 1; foreach (@words_array){ if($jinwei == 1) { if($_ =~ /^[a-z]$/){ $_ = uc $_; $jinwei = 0; }elsif($_ =~ /^[A-Z]$/){ $_ = lc $_; $jinwei = 1; } } } $words = join('',@words_array); return $words; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |