perl
痕枫冷
geek,喜欢研究技术
展开
-
perl版本猜数字
use diagnostics; use 5.010; $num = int(1 + rand 100); print "input guess number here with 10 times: \n"; while(){ $times++ if $_=~ /\d+/; if($times > 10 || $_ =~ /^[quit|exit]/i){ print "th原创 2012-07-10 23:41:52 · 997 阅读 · 0 评论 -
计算指定文件夹下文件总数
use strict; use File::Find; print "输入你要计算文件数量所属目录的路径: \n"; chomp(my $dir = ); print "正在计算,请稍后...\n"; BEGIN{ my $count = 0; sub count_num { $count++ if -f } sub count_get { $count } } find(\&c原创 2013-01-04 10:33:47 · 793 阅读 · 0 评论 -
计算工程中总共有多少行代码
use strict; use File::Find; print "input your dir here: \n"; chomp(my $dir = ); print "counting,please waiting...\n"; find(\&wanted,$dir); my $line_count; sub wanted{ if(-f $_){ my $file = $_;原创 2013-01-04 10:36:30 · 888 阅读 · 0 评论 -
ruby 版,JavaBean的另一种优雅写法——Builder的代码生成器
template="public class " attr_types =[] attr_names = [] index=0 File.open("Test.txt"){ |f| file_name=nil file_obj=nil cls_name=nil attr_name=nil f.each_line do |line| line="#{line}".gsub("\n"原创 2013-07-22 00:36:58 · 1305 阅读 · 0 评论