又写了一段Perl,帮同事减轻负担....就是搜索pas文件,提取信息而已。
use warnings; use strict; use File::Find; $/ = undef; find(\&subprocess, "E:\\GpsClient"); sub subprocess { processfile($_) if /.pas$/; }; sub processfile { open(FH, shift); my $contents = <FH>; my $DBTableName = $1 if $contents =~ /DBTableName\s*:=\s*\‘(.*)\‘/i; my $DBTableCHNName = $1 if $contents =~ /DBTableCHNName\s*:=\s*\‘(.*)\‘/i; my %dict = $contents =~ /AddField\s*\(\‘(.*?)\‘\s*,\s*\‘(.*?)\‘/gi ; if ($DBTableName) { print "$DBTableName:($DBTableCHNName) \n"; foreach my $key ( keys %dict ) { print ‘Field‘, "\t", $key, " \t ", $dict{$key}, "\n"; } print "-" x 32, "\n\n"; }; close(FH); }
运行方式 xx.pl > c:\1.log
原文:http://my.oschina.net/huanghongqiao/blog/344093